Bi-directional Map in Java? [duplicate]

You can use the Google Collections API for that, recently renamed to Guava, specifically a 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.

Leave a Comment