需要将对应的list换成本地list,和对象换成本地对象
// 根据一个字段分组
Map<String, List<String>> map = objectLists.stream()
.collect(Collectors.groupingBy(
Object::getName,
Collectors.mapping(Object::getId, Collectors.toList())));
// 根据多个字段分组
Map<String, List<Object>> groupMap = objectLists.stream().collect(
Collectors.groupingBy(s->s.getId()+s.getName()));
// 把某属性作为key,对应的Object对象作为value
Map<String, List<Object>> groupMap = objectLists.stream().collect(
Collectors.groupingBy(Object::getName));
Map<String, List<String>> studentMap = studentList.stream()
.collect(Collectors.groupingBy(
Object::getId,
Collectors.mapping(Object::getName, Collectors.toList())
));