top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Java: How to implement duplicate key for a HashMap?

+1 vote
738 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
...