“Foreach Java” Kode Jawaban

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

Untuk setiap loop 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

Metode Foreach Java

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

Java for-ever loop

// 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

Jawaban yang mirip dengan “Foreach Java”

Pertanyaan yang mirip dengan “Foreach Java”

Lebih banyak jawaban terkait untuk “Foreach Java” di Java

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya