When maintaining a HashMap, merge is a very useful command. I like the concise way to add a number to a sum using expressions like
map.merge(key, value, Double::sum);
I have a HashMap<String, List> that I want to update. I could use something like
if (!map.containsKey(key)) map.put(key, new List());
map.get(key).add(value);
is there a more elegant way using merge to achieve this?