loop in array java code example
Example 1: lopp array java
For(<DataType of array/List><Temp variable name> : <Array/List to be iterated>){
System.out.println();
}
Example 2: loop through array java
public class HelloWorld {
public static void main(String[] args) {
String[] family = new String[] {"Member1", "Member2", "Member3", "Member4", "Member5"};
for(String name : family)
{
System.out.println(name);
}
}
}
Example 3: for loop in java as long as array
for(i = 0; i < arrayName.length; i++{
System.out.println(arrayName[i]);
}
Example 4: java loop through array
String[] elements = {"a", "a", "a", "a"};
for (String s: elements) {
System.out.println(s);
}