“Java foreach -Methode” Code-Antworten

Java foreach

List<String> someList = new ArrayList<String>();
// add "monkey", "donkey", "skeleton key" to someList
for (String item : someList) {
    System.out.println(item);
}
Bright Beaver

Foreach Java

for (String name : names) {
    System.out.println(name);
}
Itchy Ibis

Java foreach -Methode

names.forEach(name -> {
    System.out.println(name);
});
Grotesque Gazelle

Für jede Java

class For_Each    
{
    public static void main(String[] arg)
    {
        {
            int[] marks = { 125, 132, 95, 116, 110 };
             
            int highest_marks = maximum(marks);
            System.out.println("The highest score is " + highest_marks);
        }
    }
    public static int maximum(int[] numbers)
    {
        int maxSoFar = numbers[0];
         
        // for each loop
        for (int num : numbers)
        {
            if (num > maxSoFar)
            {
                maxSoFar = num;
            }
        }
    return maxSoFar;
    }
}
Said HR

Ähnliche Antworten wie “Java foreach -Methode”

Fragen ähnlich wie “Java foreach -Methode”

Weitere verwandte Antworten zu “Java foreach -Methode” auf Java

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen