Arrays replace pointer arithmetic. They're created with the new operator:
|
Indexing is 0-based.
|
No multi-dimensional arrays. Must use arrays of arrays:
-
int i[][] = new int[3][4];
|
Brackets may follow array element type. The following are equivalent:
-
int iarray[];
-
int[] iarray;
-
byte f(int n)[];
-
byte[] f(int n);
|
Array bounds checking occurs at runtime.
|
The length of an array can be found by using .length:
-
int a[][] = new int[10][3];
-
System.out.println(a.length); // prints 10
-
System.out.println(a[0].length); // prints 3
|