I want to get all the values associated with a key in Map. For e.g,
Map tempMap = new HashMap(); tempMap.put('1','X'); tempMap.put('2','Y'); tempMap.put('3','Z'); tempMap.put('1','ABC'); tempMap.put('2','RR'); tempMap.put('1','RT');
How to retrieve all the values associated with key 1 ?
What you can do is this:
This compartmentalizes values that correspond to the key ‘1’ into their own list, which you can easily access. Just don’t forget to initialize the list… else
NullPointerExceptions will come to get you.Yuval =8-)