This is an old revision of the document!


Arrays

Jagged Arrays

These are arrays of arrays. It only allocated space for each array assigned to it.

// allocate memory
int jagged[][] = new int[2][];
jagged[0] = new int[20];
jagged[1] = new int[10];
 
// use array
jagged[0][2] = 15;

Multi-Dimensional Arrays

These are arrays with more than one dimension. Memory gets allocated for the entire reserved space specified by dimensions.

// allocate memory
int array[][] = new int[2][10];
 
// use array
array[0,2] = 15;
Resources