I have gone through questions relate to the same questions, but I am not getting a clear idea of how to implement the map with duplicate entries. I was asked this question in my interview. Please give me some guidelines.
For instance, a company has two employees of same name and same area of development viz.
map.put("Tom Hank","Java");
map.put("Tom Hank","Java");
As we all know, we cannot store duplicate values in HashMap
. So can I implement this and retrieve the values according to key? Or any other better solution?
These are the questions that I have gone through but not able to understand how to do this.
How to include duplicate keys in HashMap? | How can i have a HashMap in Java with duplicate keys