“Foreach Java” 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

Für jede Schleife Java


public class Sample {
    public static void main(String[] args) {
        String names[] = { "Jasmine", "Lyka", "Marbie", "Soleen", "Tiny" };
        for (String name : names) {
            System.out.println(name);
        }
    }
}
Fernandez, Jasmine M.

Java foreach

for (String item : someList) {
    System.out.println(item);
}
Alina Samatova

Java foreach -Methode

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

Java For-Each-Schleife

// print array elements 

class Main {
  public static void main(String[] args) {
      
    // create an array
    int[] numbers = {3, 7, 5, -5};
    
    // iterating through the array 
    for (int number: numbers) {
       System.out.println(number);
    }
  }
}
SAMER SAEID

Ähnliche Antworten wie “Foreach Java”

Fragen ähnlich wie “Foreach Java”

Weitere verwandte Antworten zu “Foreach Java” auf Java

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen