1 package people; 2 3 public class PersonDemo2 { 4 5 public static void main(String[] args) { 6 Person[] people = new Person[6]; 7 people[0] = new Person( "Bob Dylan", 5, 24, 1941 ); 8 people[1] = new Person( "Noomi Rapace", 12, 28, 1974 ); 9 people[2] = new Person( "Pharrell Williams", 4, 5, 1973 ); 10 people[3] = new Person( "Frank Sinatra", 12, 12, 1915 ); 11 people[4] = new Person( "Diana Krall", 11,16,1964 ); 12 people[5] = new Person( "Miguel Cruz", 4,6,2000); 13 14 System.out.println("\nThe people array ..."); 15 16 //Regular way 17 18 /*for(int i =0; i<people.length; i++) { 19 System.out.println(people[i]); 20 }*/ 21 22 //Alternative way of using loop 23 for(Person personElement: people) { //For each element in array "people" 24 System.out.println(personElement); // print out the elements/data (in this case objects) within the array 25 } 26 27 } 28 }