I have a java.util.Map for a key-type class Foo. Let\'s call the instance of the map map.
java.util.Map
Foo
map
I want to add {
You can do:
map.put(foo, f + map.getOrDefault(foo, 0d));
The value here will be the one that corresponds to foo if present in the Map or 0d, otherwise.
foo
Map
0d