AP® Computer Science A glossary
2D array
Also called: two-dimensional array, array of arrays
Course: AP® Computer Science A Shows up in: Unit 4: Data Collections
An array of arrays that stores related data in rows and columns; each element is reached with arr[row][col].
Appears in the course and exam description (CED): 4.11.A.14.11.A.34.11.A.44.11.A.6
A two-dimensional (2D) array is stored as an array of arrays: each row is a 1D array. Its size is fixed when it is created. The number of rows is arr.length and the number of columns is arr[0].length. On the AP® exam the first index is the row and the second is the column, and every 2D array is rectangular.
Example
int[][] seats = { {1, 0, 1},
{0, 0, 1} };
System.out.println(seats.length + " rows, " + seats[0].length + " columns");
System.out.println(seats[1][2]); // row 1, column 2: prints 1 Learn it properly, with a checkpoint 4.11 2D Array Creation and Access