1.取集合嵌套的集合中,对应对象的某个值,形成list
list.stream().flatMap(x->x.getGoodsList().stream()).map(x->x.getId()).collect(Collectors.toList());
2.按某个属性分组,并按另一个属性取最大
studentList.stream()
.collect(Collectors.toMap(Student::getClassId, Function.identity(),
(c1, c2) -> c1.getAge() > c2.getAge() ? c1 : c2))
.values();