createStudentAndSelectCourse里为什么不能用Student student?而要先在外面添加属性Student再在这里面用?
public void createStudentAndSelectCourse(){ student = new Student("1","小明"); System.out.println("欢迎学生" + student.name + "选课!"); 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.course.add(cr); } } } for(Course cr:student.course){ System.out.println("已选课程:"+ cr.id + ":" + cr.name); } }