2D Arrays
A 2D array is a grid (rows and columns).
Example:
int[][] grid = {
{1, 2},
{3, 4}
};
int[][] matrix = new int[rows][columns]
System.out.println(grid[1][0]); // 3
This accesses the second row and first column.
Traversing:
for(int r = 0; r < grid.length; r++){
for(int c = 0; c < grid[r].length; c++){
System.out.println(grid[r][c]);
}
}
The outer loop goes through rows and the inner loop goes through columns.