MultidimensionalArrayDRAFT
When we allocate a multi-dimensional array e.g., with new int[x][y][z]
,
one single array object is created, which directly provides space for all the elements.
A multi-dimensional array is one thing
A multi-dimensional is a structure of nested arrays
CorrectionHere is what's right.
In Java, a multi-dimensional array is simply an array of arrays (of arrays, of arrays, of …). Thus:
int[][][] a3 = new int[4][5][6];
int[][] a2 = a3[0];
int[] a1 = a3[0][0];
int i = a3[0][0][0];
a3
is a three-dimensional array, but, really, it just is an array with 4 elements, each of the elements is of type int[][]
(an array of array of int). So, a3
is an array which contains 4 references to 4 arrays, which each contains 5 references to 5 arrays, which each contain 6 int
s. We assign the value of the 0th element of a3
to a2
, which is a two-dimensional array.