Hi
Say I have two hashmaps:
- {dog=1, cat=1, sport=3, golf=4}
- {dog=5, person=1, animal=4}
I want to merge them retaining the values, so that the values add together in the output
Output:
{dog=6, person=1, animal=4, cat=1, sport=3, golf=4}
Notice how "dog" has a value of 6 (5+1)
Using Hashmap.putAll(), the value of dog becomes 5, any ideas how I can merge these retaining the values?
Many thanks, Philip