日期:2014-05-20 浏览次数:20759 次
public class Course { private String name; [u]private String[] students = new String[100]; //在这里创建[/u] private int numberOfStudents; public Course(String name) { this.name = name; [u] //students = new String[100]; // 或者在这里创建[/u] } public String getName() { return name; } public void addStudent(String student) { students[numberOfStudents] = student; numberOfStudents++; } public String[] getStudents() { return students; } public int getNumberOfStudents() { return numberOfStudents; } }