9.2 Accessing Multidimensional Array Elements

Elements of a two-dimensional array are accessed using this syntax:

arrayName[exp1][exp2]


   where exp1 and exp2 are expressions that evaluate to integers.

Exp1 is the element’s row position, or row index, within the two-dimensional array. Exp2 is the element’s column position, or column index, within the two-dimensional array. The row index of the first row is always 0; the row index of the last row is always 1 less than the number of rows. The column index of the first column is always 0. The column index of the last column is always 1 fewer than the number of columns in that row.

Because a two-dimensional array is an array of arrays, the length of a two-dimensional array is its number of arrays, ...

Get Java Illuminated, 5th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.