Multidimensional Arrays
The arrays thus far in the hour all have one dimension, so you can retrieve an element using a single number. Some types of information require more dimensions to store adequately as arrays, such as points in an (x,y) coordinate system. One dimension of the array could store the x coordinate, and the other dimension could store the y coordinate.
To create an array that has two dimensions, you must use an additional set of square brackets when creating and using the array, as in these statements:
boolean[][] selectedPoint = new boolean[50][50];selectedPoint[4][13] = true;selectedPoint[7][6] = true;selectedPoint[11][22] = true;
This example creates an array of Boolean values called selectedPoint. The array has 50 elements ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access