Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a map or list in java that allows associating two objects with eachother? [duplicate]

Tags:

java

I would need a list/map like a HashMap where i can easily access either 'side' by simple passing the object and retrieving the other thing.

I need to be able to use get(key) and retrieve the value as well as get(value) and retrieve the key AND i want to be able to set a new key or value.

Is there already something like that ?

like image 321
NikkyD Avatar asked Dec 29 '25 20:12

NikkyD


1 Answers

Two popular choices are

  • Guava's BiMap
  • Apache Commons BidiMap
like image 68
Xipo Avatar answered Jan 01 '26 11:01

Xipo