1. 分组
代码语言:javascript复制Map<Integer, List<Entity>> groupBy
= entityList.stream()
.collect(Collectors.groupingBy(Entity::getGrouper));
2. 转MAP
代码语言:javascript复制Map<Integer, Entity> entityMap
= entityList.stream()
.collect(Collectors.toMap(Entity::getKey, entity -> entity));
文章知识点与官方知识档案匹配,可进一步学习相关知识