iterate over arrays code example
Example 1: how to loop through an array
int[] numbers = {1,2,3,4,5};
for (int i = 0; i < numbers.length; i++) {
System.out.println(i);
}
Example 2: loop over an array
let fruits = ['Apple', 'Banana'];
fruits.forEach(function(item, index, array) {
console.log(item, index);
});
Example 3: 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);
});