June 2025
Intermediate to advanced
1129 pages
53h
English
Java implements multidimensional arrays as arrays of arrays. Multidimensional arrays can be used, for example, for representing mathematical matrices or raster images. This section describes how you can initialize, build, and use objects for multidimensional arrays.
The following code declares a two-dimensional array matrix with space for a total of 32 cells, arranged in 4 rows and 8 columns:
int[][] matrix = new int[ 4 ][ 8 ];
Multidimensional arrays are basically arrays with arrays as elements and can be easily declared.
As with one-dimensional arrays, multidimensional arrays can be initialized immediately during their creation, as in the following example:
int[][] matrix3x2 = { {1, 2}, {2, 3}, {3,
Read now
Unlock full access