In map we have key, value pair.If we try to put same key in map 2 times it will produce a error.Now i want similar kind of behavior for value too.In short when i put a new key,value into the map both key and value should be unique, or else it should through an exception, How can i achive this?
Sounds like you want a Guava Bimap
.
A bimap (or "bidirectional map") is a map that preserves the uniqueness of its values as well as that of its keys. This constraint enables bimaps to support an "inverse view", which is another bimap containing the same entries as this bimap but with reversed keys and values.
(Guava is a great library in general, btw. Well worth using.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With