10/01/2008

Arrays

How to declare arrays:

int array = new int[5];
(the length of the array is 5)

How to initialize an array:
There are a couple of ways to initialize an array.

int array = {1,2,3,4,5}; 
 or
int array = new int[5]
array[0] = 1;
...
array[4] = 5;

How to refer to elememts of the array:

array[0]--> the frist element 
array[4] --> the last element of this array