A rather common task is to model some relationship between two kinds of objects. Often you only need to go from a key to its value, and you will use a standard Map, but sometimes you will have to go back from the “value” to the “key”. In cases like this, the common solution is to build two maps: Map a2b = new HashMap<>(); Map b2a = new HashMap<>(); a2b.