View RSS Feed

Java Array

Multidimensional arrays

Rate this Entry
by , 03-04-2012 at 11:24 AM (581 Views)
Array of arrays also consists of multi dimensional arrays. Multi-dimensional variables could be declared by specifying the every extra index. This is done by using square bracket set.
Java Code:
For example: 
int myArray[ ][ ] = new int[5][6] ;
In case of a multi-dimensional array, memory is allocated by specifying memory for leftmost (1st) dimension.

Rest of the dimensions can be allocated separately.

In multi-dimensional array, every array’s length is in one’s control.

Multi-dimensional array’s declarations will be better explained by the given example:
Java Code:
int myArray[][] = new int[4][];
myArray [0] = new int[5];
myArray [1] = new int[6];
myArray [2] = new int[7];
myArray [3] = new int[8];

Submit "Multidimensional arrays" to Facebook Submit "Multidimensional arrays" to Digg Submit "Multidimensional arrays" to Submit "Multidimensional arrays" to StumbleUpon Submit "Multidimensional arrays" to Google