Q:

how to implement below data structure in java using collection framework

I have below data structure like this 
Country,StateID1 where StateID1 contains "City1","City2","City3" etc
Country,StateID2 where StateID2 contains "City1","City2","City3" etc

I know i can't use HashMap to implement above data structure because if i add StateID2 to same Country StateID1 will be replace with StateID2
for eg 
map.put("1","1111");
map.put("1","2222");
output

 key:value
 1:2222`

i am facing hard time to figure out how to do this. I need some support from you guys

A:

You could create a class for the same.
class YourClass
{
     String country;
     State state;
}

class State
{
    Set<String> cities;
}

You can then use this class as a data structure. You don't really need to use Collections framework for the same.
OR
If you really want to do it using Collections, then you can use a combination of Country and StateId as the key, and the list of cities as the value in a Map. For ex:
String country = "1";
String state = "1";
String separator = "-" // You could use any separator
String key = country + separator + state;
Set<String> cities = new HashSet<String>();
cities.add("1");
cities.add("2");

Map<String, Set<String>> map = new HashMap<>(); 
map.put(key, cities);

So your key would be 1-1 and value would be 12.

