When declaring a variable with a type modifier, the type modifier affects the type of all variables in the list. Example:
int[] a, b, c;
a
, b
, and c
are now arrays of integers.
When declaring arrays it is possible to define the initial size of the array by passing the length as a parameter to the constructor. The elements can also be individually initialized by specifying an initialization list. Example:
int[] a; // A zero-length array of integers int[] b(3); // An array of integers with 3 elements int[] c = {,3,4,}; // An array of integers with 4 elements, where // the second and third elements are initialized
Each element in the array is accessed with the indexing operator. The indices are zero based, i.e the range of valid indices are from 0 to length - 1.
a[0] = some_value;
An array also have two methods. length() allow you to determine how many elements are in the array, and resize() lets you resize the array.