I have used compute method as well as merge method. However I am still not sure how merge method differs from compute methods.
I was asked a question in interview to maintain a counter of hits for given list of IP addresses. It was a basic implementation of Map where key is the IP and value is the number of hits.
I implemented it with computeIfAbsent method but that was not sufficient when the key is present so I had to change the implementation to use merge method.
Can we say that merge is equivalent to using both compute methods at same time?