Multiset in java

what is the equivalent of multiset in java?

You can use a map of item to count. No built in multiset

I’m confused - is there a datastructure in Java that not only sorts the elements as you put them in, but also doesn’t allow duplciates. I know there’s TreeSet but it doesn’t allow duplicates. Map doesn’t sort the elements as you put them in right? Unless you maybe use TreeMap… pls advise thanks

TreeMaps sort in respect to keys. You can use TreeMaps in place of multisets and store the values as the keys and the frequency as the values. It’s talked about more in the above link if you look at the java section.

aight bet thx - i was a bit confused how to use treemap but looking at the link benq posted it makes more sense now