A 2D array is a table: cells live at table[row][column], and nested loops walk them row by row.
1 Grid of cells
A 2D array is rows and columns — you address a cell with grid[row][column].
2 Two sizes
int[][] grid = new int[2][3] makes 2 rows, each with 3 zero-filled cells.
3 Nested loops fill it
The outer loop walks rows, the inner loop walks the columns of each row.
4 Two lengths
grid.length counts rows; grid[0].length counts the cells in row 0.
From row to grid
Grid of cells1A 2D array is rows and columns — you address a cell with grid[row][column]. Two sizes2int[][] grid = new int[2][3] makes 2 rows, each with 3 zero-filled cells. Nested loops fill it3The outer loop walks rows, the inner loop walks the columns of each row. Two lengths4grid.length counts rows; grid[0].length counts the cells in row 0.
4 building blocks make up From row to grid
Press play: the outer loop picks a row, the inner loop sweeps its columns, and total grows cell by cell.
JVMThe JVM loads the GridDemo class into memory.
Memory
no variables yet — press play
Console
output appears as the program runs…
Each row of a 2D array is its own array. Play the script to fill one flat row of grid cells.
Drag to orbit the scene. Press Play to watch memory in action.
Click a term, then click its meaning to lock the pair.
6 conceptsTap a card to expand ?int[][] griddrops into place
?new int[2][3]drops into place
?grid[1][0]drops into place
?grid.lengthdrops into place
?grid[0].lengthdrops into place
?nested loopdrops into place
A nested loop visiting every cell of a tiny grid.
Your predicted output — one line per console line
Hint: The nested loops visit every cell row by row, left to right. Each value is multiplied by 10 before printing.
01A 2D array is a grid: table[row][column], both indexes starting at 0.
02new int[2][3] makes 2 rows of 3 zero-filled cells.
03Nested loops are the natural fit: outer loop = rows, inner loop = columns.
04grid.length is the row count; grid[0].length is the column count.
05Writing grid[1][2] means row 1, column 2 — row index first, always.