1 |
A variable is either a primitive type such as int, float or double, or it is an object.
|
2 |
Arrays are objects, but have a special syntax for creating and indexing, more like C and C++.
-
int states [ ]; declares the states variable to be a 1D array of ints
-
states = new int [ 128 ]; creates the new 1D array of length 128
-
states [ 27 ] = i + 1; assigning to an element
|
3 |
Multi-dimensional arrays are arrays of arrays
-
char states [ ] [ ] = new char [12 ] [ 24 ]; delaring and creating at the same time
-
they can also be "ragged"
|
4 |
Arrays can have values that are any type of object
-
Color hues = new Color [ 1024 ];
|