loop over array of objects java code example
Example 1: java loop through array
class LoopThroughArray {
public static void main(String[] args)
{
int[] myArr = {1, 2, 3, 4};
for(int i : myArr){
System.out.println(i + "\n")
}
/* Output:
1
2
3
4
*/
}
}
Example 2: how to iterate in array of array
var printArray = function(arr) {
if ( typeof(arr) == "object") {
for (var i = 0; i < arr.length; i++) {
printArray(arr[i]);
}
}
else document.write(arr);
}
printArray(parentArray);