1.初始化数组的长度
2.初始化每个元素对象
3.调用每个对象的方法
public class Student {
private String name; public Student() {} public Student(String name) {
this.name = name;
} public String getName() {
return name;
} public static void main(String[] args) {
// 创建对象数组
Student[] students = new Student[3];
students[0] = new Student("jack");
students[1] = new Student("mary");
students[2] = new Student("wendy"); for (int i = 0; i < 3; i++) {
System.out.println(students[i].getName());
}
}
}