A multi-dimensional array of dimension n (i.e., an n-dimensional array or simply n-D array) is a collection of items which is accessed via n subscript expressions. For example, in a language that supports it, the element of the two-dimensional array x is accessed by writing x[i,j].
The Java programming language does not really support multi-dimensional arrays. It does, however, support arrays of arrays. In Java, a two-dimensional array x is really an array of one-dimensional arrays:
int x = new int;The expression x[i] selects the one-dimensional array; the expression x[i][j] selects the element from that array.
The built-in multi-dimensional arrays suffer the same indignities that simple one-dimensional arrays do: Array indices in each dimension range from zero to , where length is the array length in the given dimension. There is no array assignment operator. The number of dimensions and the size of each dimension is fixed once the array has been allocated.
In order to illustrate how these deficiencies of the Java built-in multi-dimensional arrays can be overcome, we will examine the implementation of a multi-dimensional array class, MultiDimensionalArray, that is based on the one-dimensional array class discussed in Section .