I want a data structure that allows me to map keys to values, like PHP’s associative arrays. Each key can only exist once, but a value can be mapped to any number of keys. What am I looking for? Something in the Google Commons Collections?
Share
The
Mapstructure is what you want. A good implementation is theHashMap.This data type does not allow the same value for the Key, but you can have as many duplicate values as you like.
Example usage:
In other words, the key can only exist once. Otherwise the value is overwritten.