Is there a way we can group by Key and add the value in a HashMap in Java
HashMap<String, Integer> map = new HashMap<String, Integer>();
map.put("A", 2);
map.put("A", 3);
map.put("B", 4);
map.put("A", 5);
map.put("B", 4);
The result is
A = 10
B = 8
Any help would be helpful !!!