1 //A second Person Demo that is using an array of Person Objects 2 3 package people; 4 5 public class PersonDemo2 { 6 //Create the Array 7 public static void main(String[] args) { 8 Person[] array = new Person[6]; 9 array[0] = new Person("Bob Dylan", 5, 24, 1941); 10 array[1] = new Person("Noomi Rapace", 12, 28, 1974); 11 array[2] = new Person("Pharrell Williams", 5, 5, 1973); 12 array[3] = new Person("Frank Sinatra", 12, 12, 1915); 13 array[4] = new Person("Diana Krall", 11, 16, 1964); 14 array[5] = new Person("Ray Fisher", 2, 15, 2000); 15 16 //Use a for loop to textually display the objects 17 for (int i = 0; i < array.length; i= i+1) { 18 String name = array[i].firstName() + " " + array[i].lastName(); 19 String birthday = array[i].month() + "/" + array[i].day() + "/" + array[i].year(); 20 String initials = array[i].initials(); 21 boolean boomer = array[i].isBoomer(); 22 System.out.println(name + ", born " + birthday + " " + initials + " " + boomer); 23 } 24 } 25 } 26 27