import java.util.Random; public class Driver { public static void main(String [] args) { final int SIZE = 40; final int SENIOR = 65; Random aGenerator = new Random(); int temp; // Step 1: create the array variable Person [] myFriends; // Error: no array created yet // myFriends[0] = new Person(); // Step 2: Create array myFriends = new Person[SIZE]; // Error: each array element is null, no people objects created yet // myFriends[0].getAge(); // Step 3: add elements to the array/create Person objects for (int i = 0; i < SIZE; i++) { temp = aGenerator.nextInt(100); myFriends[i] = new Person(temp); } // Only show friends who are senior citizens for (int i = 0; i < SIZE; i++) { temp = myFriends[i].getAge(); if (temp >= SENIOR) System.out.println(temp); } } }