Java8:HashMap 到HashMap 使用StreamMap-ReduceCollector

Java8:HashMap 到HashMap 使用StreamMap-ReduceCollector,第1张

Java8:HashMap 到HashMap 使用Stream / Map-Reduce / Collector
Map<String, String> x;Map<String, Integer> y =    x.entrySet().stream()        .collect(Collectors.toMap( e -> e.getKey(), e -> Integer.parseInt(e.getValue())        ));

它不如列表代码那么好。您不能

Map.Entry
map()
通话中构造new ,因此工作会混入
collect()
通话中。



欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/zaji/5178059.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-11-18
下一篇2022-11-18

发表评论

登录后才能评论

评论列表(0条)

    保存