References to Objects
Book B = new book ();
Book C = new book ();
Book d = C; //Declares a new book reference variable, but does not create a new book object and assigns the value of variable C to the variable d. This means "copy the byte combination of C to variable D", where C and D are referenced to the same object.
c = b; //b and C both refer to the same object.
An array is like a cup holder
int [] nums; //declare an int array variable. Array variable is the remote control of an array object
nums = new int [7]; //Create an array of size 7 and assign it to a variable previously declared as int[] nums
nums [0] = 6;......nums[6] = 1; //assigns to each element in the array.
Create a dog array
Dog [] pets; //Declare a dog array variable
Pets = new Dog[7]; //Create a dog array of size 7 and assign values to the dog[] type variable pets declared earlier.
Pets [0] = new Dog (); //Create new Object dog objects and assign them to the elements of the array
Pets [1] = new Dog ();
How do I access the dog in the dog array?
Only the array index (position) is required to manipulate specific objects
Dog [] mydogs = new dog [3];
mydogs [0] = new Dog ();
mydogs [0]. Name = "Fido";
mydogs [0]. Bark ();
"Head first Java"--Recognize variables