In this example we will show the method to loop through a multidimensional array in Java.
Source Code
package com.beginner.examples;
public class LoopArrays {
public static void main(String[] args) {
int[][] nums = {{0}, {1, 3}, {2, 4}};
for (int i = 0; i < nums.length; i++) { // loop through a multidimensional array
for(int j = 0; j < nums[i].length; j++) {
System.out.println(nums[i][j]);
}
}
}
}
Output:
0
1
3
2
4