• An object reference variable holds the memory address of an object • Rather than dealing with arbitrary addresses, we often depict a reference graphically as a “pointer” to an object • For object references, assignment copies the memory location: jane john jane john
of Objects • The elements of an array can be object references. • Suppose that we have the Student class Student[] list = new Student[5]; //The following causes NullPointerException int id = list[0].getID(); //We need to instantiate each object first: list[0] = new Student(“Bob”); list[1] = new Student(“Mary”); list[2] = new Student(“Peter”); // ... // OR we can use the Initializer: Student[] list = {new Student(“Bob”), new Student(“Mary”), new Student(“Peter”) };