Skip to content
Advertisement

HashMap: One Key, multiple Values

How I can get the third value for the first key in this map? Is this possible?

Advertisement

Answer

Libraries exist to do this, but the simplest plain Java way is to create a Map of List like this:

Map<Object,ArrayList<Object>> multiMap = new HashMap<>();
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement