Java: Multidimensional Arrays
Multidimensional arrays can hold data in different rows, and different columns.
We create a multidimensional array like so:
int ArrayOne[][]={{32,45,12,91}, {98,72,4,7,88}};
When creating a multidimensional array you need two opening and closing square brackets, one for the columns and one for the rows.
In my example there are two rows (in the different sets of curly brackets), in the first row there are four columns; 32, 45, 12, and 91. In the second row there are five columns; 98, 72, 4, 7, and 88.
To refer to the multidimensional arrays we give the row number and then the column number (remember computer start counting from zero), for example this:
System.out.println(ArrayOne[0][0]);
Would display 32.
and this:
System.out.println(ArrayOne[1][2]);
Would display 4.
Back to Java

