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()通话中。

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()通话中。