Java – calculate occurrences in Multimap
•
Java
I have a Multimap with multiple similar values:
{Entertainment=[5],Food=[2,2,2],Products=[11],Health & Beauty=[3]}
How to calculate the total number of these keys as follows?
Entertainment = 1 Food = 3 Products = 1 Health & Beauty = 1
The number in the array is the category ID, so food appears three times
Solution
multimap. get(key). Size () or Multimap keys(). Count (key) should work
Documentation
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码