How to loop a map elements and multiply value by lets say number 20 in java8 and get result?
I don't want to loop in usual for loop i want to make it efficient.
How to loop a map elements and multiply value by lets say number 20 in java8 and get result?
I don't want to loop in usual for loop i want to make it efficient.
You can use replaceAll
if you want to mutate the map itself:
myMap.replaceAll((k, v) -> v * 20);
or collect to a new map:
myMap.entrySet()
.stream()
.collect(Collectors.toMap(Map.Entry::getKey, e -> e.getValue() * 20));