loop array of integers java code example
Example 1: 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 2: iterate through an array
var arr = [1,2,3,4,5,6,7,8];
for(var i= 0, l = arr.length; i< l; i++){
console.log(arr[i]);
}
console.log("========================");
arr.forEach(function(item,index){
console.log(item);
});