Here is my code:
public static HashMap<String, ArrayList<String>> CountryMap = new HashMap<String, ArrayList<String>>();
ArrayList<String> stateInd = new ArrayList<String>();
ArrayList<String> stateUSA = new ArrayList<String>();
stateInd.add("GJ");
stateInd.add("MP");
stateUSA.add("NJ");
stateUSA.add("NY");
CountryMap.put("India",stateInd);
CountryMap.put("USA",stateUSA);
for(int i=0;i<CountryMap.size();i++){
for (Entry<String, ArrayList<String>> entry : CountryMap.entrySet()) {
if (entry.getKey().equals("India") {
ArrayList<String> result = new ArrayList<String>();
# how to add Value of CountryMap with "India" as a Key to result ArrayList??
}
}
}
I want to add values to another ArrayList from hashmap which have "India" as key ?
I tried..
result.add(CountryMap.get("India"));
But it didn't worked. It add all values.