Map<Integer, Student> map = new HashMap<Integer, Student>();
for (Student e : students) {
int id = e.getStudentNo();
if (map.containsKey(id)) {
double score = map.get(id).getScore();
score += e.getScore();
map.get(id).setScore(score);
} else {
map.put(id, e);
}
System.out.println(map);
}
System.out.println(map);
for (Student e : students) {
int id = e.getStudentNo();
if (map.containsKey(id)) {
double score = map.get(id).getScore();
score += e.getScore();
map.get(id).setScore(score);
} else {
map.put(id, e);
}
System.out.println(map);
}
System.out.println(map);