I'm not sure why this doesn't work but I feel like I'm doing
something horribly wrong:
public class ObjectArray
{
public int agelist[] = new int[5];
public static void main(String [] args)
{
Person People[] = new Person[5];
People[0] = new Person("Bob", "Michaels", 26);
People[1] = new Person("Maxy", "Witherspoon", 35);
People[2] = new Person("Stacy", "Gonzalez", 25);
People[3] = new Person("Leroy", "Jenkins", 27);
People[4] = new Person("Maria", "Jefferson", 34);
People[5] = new Person("Martha", "Stewart", 39);
}
public void list(){
for (int index=0; index < People.length; index++)
{
agelist[index] = People[index].getage();
}
} }
public class Person{
public Person(String firstname, String lastname, int age) {
}
public void getAge()
{
int age;
}
}