top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration Why to Join

Facebook Login
Site Registration

Java: How to implement duplicate key for a HashMap?

+1 vote
125 views

Example
Map data = new HashMap();
data.put("a","America");
data.put("a","Africa");
data.put("b","Bangladesh");

Need to have both "America" and "Africa" as value against key "a". Is there any mechanism to achieve this scenario.

posted Jun 16, 2015 by anonymous

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

use

Map<String,List> data = new HashMap();

{a:[America,Africa] ,b:[Bangaldesh]}

answer Jul 31, 2015 by Vikalp Kumar
Contact Us
+91 9880187415
sales@queryhome.net
support@queryhome.net
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Bangalore-560102
Karnataka INDIA.
QUERY HOME
...