<<< Two-dimensional array examples | Index | jagged array >>> |
Code that processes a rectangular array with nested for loops
int[][] numbers = { { 1, 2 }, { 3, 4 }, { 5, 6 } }; for (int i = 0; i < numbers.length; i++) { for (int j = 0; j < numbers[i].length; j++) { System.out.print(numbers[i][j] + " "); } System.out.print("\n"); }
The console output
1 2 3 4 5 6
<<< Two-dimensional array examples | Index | jagged array >>> |