1/24
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai |
|---|
No analytics yet
Send a link to your students to track their progress
2D array
A Java structure that stores values in a grid of rows and columns, accessed with two indices (row and column).
Array of arrays
How Java implements a 2D array: the outer array holds references to inner arrays (rows).
Outer array
In a 2D array, the top-level array whose elements are the row arrays; its length is the number of rows.
Inner array (row)
In a 2D array, an element of the outer array that stores the columns for one row.
Rectangular 2D array
A 2D array where every row has the same number of columns.
Ragged (jagged) array
A 2D array where different rows can have different lengths because each row is a separate inner array.
0-indexed
Java arrays start at index 0; valid indices run from 0 to length − 1.
2D array declaration
The statement that defines a 2D array variable’s type (e.g., int[][] grid;), without allocating storage yet.
2D array allocation
Using new to create the grid structure in memory (e.g., new int[3][4] for 3 rows and 4 columns).
Initializer list
A literal way to create and fill a 2D array at once (e.g., int[][] a = {{1,2},{3,4}};).
Default array values
Values automatically placed in a newly allocated array: numbers default to 0, booleans to false, and object references to null.
Element access (grid[r][c])
Reading or writing a specific cell in a 2D array using row index r first, then column index c.
grid.length
The number of rows in a 2D array (the length of the outer array).
grid[r].length
The number of columns in row r (the length of the inner array at index r).
ArrayIndexOutOfBoundsException
A runtime error that occurs when code uses an index that is outside the valid range for an array.
Row-major order traversal
Visiting a 2D array row by row: outer loop over rows, inner loop over columns in that row.
Column-major order traversal
Visiting a 2D array column by column: outer loop over columns, inner loop over rows (generally safest for rectangular arrays).
Enhanced for loop (for-each)
A loop style that iterates through rows and elements without explicit indices; convenient for read-only traversals.
Accumulator
A variable (like sum, count, or max) updated during traversal to build a final result.
Off-by-one error
A boundary mistake where a loop goes one step too far (often from using <= instead of <).
Integer division
Division between ints that truncates the decimal part; avoided in averages by casting (e.g., (double)sum / count).
Early return
Returning from a method as soon as the answer is determined (e.g., return true when a target is found).
In-place modification
Changing the original 2D array’s elements directly inside a method (no new array returned is required).
Boundary check (neighbor access)
Verifying indices are in range before referencing adjacent cells (e.g., avoiding r-1 at the top row or c+1 at the right edge).
Null-safe String comparison
Using a literal’s equals method (e.g., "X".equals(seats[r][c])) to avoid NullPointerException when the cell could be null.