1、List转Map>
Map> demoMap = demoList.stream()
.collect(Collectors.groupingBy(Entity::getkey)); // the type of demoList is List
Entity实例getkey()方法返回的值则作为map的key,即按该字段给demoList分类。
2、Map>转List
List demoList = refDataMap.entrySet().stream()
.flatMap(map -> map.getValue().stream())
.collect(Collectors.toList()); //the type of refDataMap is Map>
3、List转Map
Map map = stats.stream().collect(Collectors.toMap(Entity::getKey,
c -> c));
Map map = stats.stream().collect(Collectors.toMap(Entity::getKey,
Entity::getStringValue)); //the type of stats if List
——未完待续———