【发布时间】:2020-09-06 16:38:29
【问题描述】:
我有一个学生类的对象列表,例如列表。学生班级有另一个班级分数的日期和对象的排序图 见下文:
class Student{
String name;
SortedMap<LocalDate, Score> semScore = new TreeMap()<>;
}
class Score{
int score;
String grade;
}
如何聚合学生列表以按学生姓名将所有排序的地图合并到一个地图组。 例如
Score score = new Score(90, "A");
SortedMap<LocalDate, Score> sMap = new TreeMap<>();
sMap.put(LocalDate.now(), score);
Student s = new Student("Bob", sMap);
So multiple records are in the list for a Student with a given name with one map of score.
I need to aggregate all the scores into the same student object like group by name.
How can we do it using java streams?
Thanks
【问题讨论】:
标签: lambda java-8 java-stream collectors