JAVA steam.collect整理

1. 分组

Map<Integer, List<Entity>> groupBy
	= entityList.stream()
	.collect(Collectors.groupingBy(Entity::getGrouper));

2. 转MAP

Map<Integer, Entity> entityMap
	= entityList.stream()
	.collect(Collectors.toMap(Entity::getKey, entity -> entity));

posted on 2020-05-12 09:32  路过君  阅读(535)  评论(0编辑  收藏  举报

导航