代码太乱了,当自己写时,懵逼了
// 创建学生对象并选课
public void createStudentAndSelectCours() {
//创建一个学生对象
student = new Student("1", "小明");
System.out.println("欢迎学生:" + student.name + "选课!");
//创建一个Scanner对象,用来接收从键盘输入的课程ID
Scanner console = new Scanner(System.in);
for (int i = 0; i < 3; i++) {
System.out.println("请输入课程ID");
String courseId = console.next();
for (Course cr : coursesToSelect) {
if(cr.id.equals(courseId)) {
student.courses.add(cr); //这里报错了,
}
}
}
}
报错原因:
The method add(Collection_ArrayList.Course) in the type Set<Course> is not applicable for the arguments (CollectionMethod.Course)