The array kids is an array of type Infant that has already been declared and initialized with Infant objects. Write a loop that prints, in a column, the names of the all of the infants in the kids array.
This is the Infant class..
public class Infant{
private String name;
private int age; // in months
public Infant(String who, int months){
name = who;
age = months;
}
public String getName(){return name;}
public int getAge(){return age;}
public void anotherMonth(){age = age + 1;}
}
The code i have tried is
for (int j = 0; j<kids.length; j++) {
System.out.println(kids.getName());
}