Two-dimensional arrays in Processing store grid data as arrays of arrays
A 2D array is an array whose elements are themselves arrays — effectively a table or grid. Declared as int[][] grid = new int[rows][cols], individual cells are accessed with grid[row][col]. The outer dimension is the row index, the inner is the column. Nested for loops iterate over all cells: for (int r=0; r<rows; r++) { for (int c=0; c<cols; c++) { … } }. Common uses include storing pixel data, cellular automata states, and tile maps.
Examples
int[][] grid = new int[5][5]; for (int r = 0; r < 5; r++) for (int c = 0; c < 5; c++) grid[r][c] = r * c;
Assessment
Implement a 10x10 grid of squares where each cell’s fill brightness is determined by its row*column index stored in a 2D array.