public class Driver { public static void main(String [] args) { // A reference to an array, array not created yet. Person [] somePeople; int i; // Create array // Each element is a reference to a Person object but note // the Person constructor hasn't been called yet to create Person // objects. (Each array element is null). somePeople = new Person[3]; // Proof that each element is null, uncomment and see what // happens // somePeople[0].setAge(10); for (i = 0; i < 3; i++) { // Create Person object, each array element will contain the // address of the newly created object. somePeople[i] = new Person(); // Because array elements now refer to an object, methods // can be invoked. somePeople[i].setAge(i); System.out.println("Age: " + somePeople[i].getAge()); } } }