stream取得Map中不重复项目的List<String>

Posted on 2020-02-29 10:31  wzhw2015  阅读(587)  评论(0编辑  收藏  举报

List<String> itemList = itemMap.entrySet().stream()

.collect(Collectors.groupingBy(e -> e.getKey().substring(11)))
.keySet()
.stream()
.map(key -> key)
.collect(Collectors.toList());

注意e.getKey().substring(11)是取出组合key的一部分项目的值

Copyright © 2024 wzhw2015
Powered by .NET 8.0 on Kubernetes