// Create and array of Person references
Person[] p = new Person[20];
// Create an actual person (s)
Person s = new Person();
// Set various bits of data
s.setData("Fred",21);
// Make the reference refer to a 'proper' object.
p[0] = new Person();
p[0].setData("Janet",30);
// ditto for the 2nd element
p[1] = new Person();
p[1].setData("alan",40);
// display everything.
s.displayData();
p[0].displayData();
p[1].displayData();
//make the first array element refer to a different object.
System.out.println("p[0] was");
p[0].displayData();
System.out.println("but now its");
p[0] = s;
s.displayData();