学习材料
https://joshhug.gitbooks.io/hug61b/content/chap2/chap24.html
Array Basic
Arrays are a special type of object that consists of a numbered sequence of memory boxes. This is unlike class instances, which have named memory boxes.
Declaration and instantiation
Example
-
int x;
gives us a 32 bit memory box that stores ints. -
Walrus w1;
gives us a 64 bit memory box that stores Walrus references. -
Walrus w2 = new Walrus(30, 5.6);
gets us 3 total memory boxes. One 64 bit box that stores Walrus references, one 32 bit box that stores the int size of the Walrus, and a 64 bit box that stores the double tuskSize of the Walrus.
Array Creation
x = new int[3];
y = new int[]{1, 2, 3, 4, 5};
int[] z = {1, 2, 3, 4, 5};