我有以下的Java代碼:一個ConcurrentModificationException的拋出未經修改
HashMap<Integer, Lesson> overflow = new HashMap<Integer, Lesson>();
HashMap<Integer, Lesson> new_lessons = this.lessons;
HashMap<Integer, Lesson> lessons = this.lessons;
for (Integer lesson : lessons.keySet()) {
if(lessons.get(lesson).getLength().equals(LessonLength.DOUBLE)){
if(lessons.containsKey(lesson + 1)){
overflow.put(lesson + 1, lessons.get(lesson + 1));
new_lessons.put(lesson+1, lessons.get(lesson));
new_lessons.get(lesson).setLength(LessonLength.ONCE);
new_lessons.get(lesson+1).setLength(LessonLength.ONCE);
}
else{
new_lessons.put(lesson+1, lessons.get(lesson));
new_lessons.get(lesson).setLength(LessonLength.ONCE);
new_lessons.get(lesson+1).setLength(LessonLength.ONCE);
}
}
}
爲什麼會出現拋出ConcurrentModificationException的?