查看所有学生一共有多少个班级
Map<String, Student> studentMap= studentList.stream()
.collect(Collectors.toMap(x -> x.getClassId(), x -> x, (x, y) -> {
log.debug(x + " Merge " + y);
return x;
}));
log.debug("studentMap: " + studentMap);
将学生按班级分组
Map<String, List<Student>> studentMap= studentList.stream()
.limit(studentList.size())
.collect(Collectors.groupingBy(Student::getClassId));
log.debug("studentMap: " + studentMap);
将学生取出集合中所有班级的所有学生
Set<Student> studentSet = studentList.stream().
filter(x -> studentMap.keySet().contains(x.getClassId()))
.collect(Collectors.toSet());
log.debug("\nfilter studentSet .size() : " + studentSet.size());
log.debug("\n");
log.debug("\n studentSet : " + studentSet );