Map<String, String> x;
Map<String, Integer> y =
x.entrySet().stream()
.collect(Collectors.toMap(
e -> e.getKey(),
e -> Integer.parseInt(e.getValue())
));
It’s not quite as nice as the list code. You can’t construct new Map.Entry
s in a map()
call so the work is mixed into the collect()
call.