【发布时间】:2018-12-13 16:08:48
【问题描述】:
我有一个 List,我需要将其转换为 Map,但键的顺序相同,因此我需要转换为 LinkedHashMap。我需要这样的东西:
list.stream().collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
但使用具体类型的地图,例如:
list.stream().collect(Collectors.toCollection(LinkedHashMap::new))
是否可以结合以上两种变体?
【问题讨论】:
标签: java stream java-stream