10/01/2008

2-dimensional arrays

How to declare 2-dimensional arrays:

int[][] array = new int[3][];

The number of the first dimensional elements must be initialized.
every value of the elements is null.

How to initialize:
array[0] = {1,2,3,4,5};
array[1] = {5,4,3,2,1};
...

or

array[0][0] = 1;

There are a couple of ways.