public Map account() {// 统计每门课程的选课人数,key代表课程,value代表人数。
Map<Course, Integer> map = new HashMap();
Iterator it = students.iterator();
while (it.hasNext()) {// 遍历所有学生
Student stu = (Student) it.next();
Iterator is = stu.getCourses().iterator();
while (is.hasNext()) {// 遍历每个学生所选的所有课程
Course cour = (Course) is.next();
map.put(cour, map.get(cour) == null ? 1 : map.get(cour) + 1);
}
}
return map;
}
//这段代码中map.put(cour, map.get(cour) == null ? 1 : map.get(cour) + 1);这段报错,如何改呢