Java Language -- More on Arrays
An array of length 128 is subscripted by integers from 0 to 127.
Subscripts are range checked in runtime and so states[-1] and states[128] will generate exceptions.
Array length can be extracted via the length instance variable, e.g.
- int len = states.length will assign len = 128.
Arrays can have dynamic sizing (a fixed size determined at runtime)
- int sizeofarray = 67;
- int states[] = new int[sizeofarray];
Multidimensional arrays are arrays of arrays
- char icon[][] = new char[16][16];
- These arrays can be "ragged":
- int graph[][] = new int[2][];
- graph[0] = new int[4];
- graph[1] = new int[7]; . . . graph[1][1] = 9;