public static void main(String[] args) {
SetTest st = new SetTest();// TODO Auto-generated method stub
st.testAdd();
st.testForeach();
Student student = new Student("131820","李宇曜");
System.out.println("欢迎学生"+student.id+' '+student.name+"选课");
Scanner console = new Scanner(System.in);
for(int i=0;i<3;i++){
System.out.println("请选择第"+i+"课程");
String courseId = console.next();
for(Course cr: st.coursesToSelect){ 为什么写coursesToSelect会报错
if(cr.id.equals(courseId)){
student.courses.add(cr);
}
public static List<Course> courseToSelect;
public ListTest(){
this.courseToSelect=new ArrayList<Course>();
}
看看你的代码是否和这个一样,规定了泛型<Course>
你看一下提示的错误信息是什么,会不会是你上面定义的时候打错了?