vendredi 30 mai 2014

Retriving data from Nested HashMap


Vote count:

0




This is my HashMap declaration:



HashMap<String, HashMap<ArrayList<String>, ArrayList<String>>> myMap;


Now I have created 2 arraylist



ArrayList<String> FirstAL = new ArrayList<String>();
ArrayList<String> SecondAL = new ArrayList<String>();


In onCreate() I have added items to arraylist and to HashMap



@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

FirstAL.add("a");
FirstAL.add("b");
FirstAL.add("c");

SecondAL.add("1");
SecondAL.add("2");
SecondAL.add("3");

myMap.put("myKey", new HashMap<ArrayList<String>, ArrayList<ArrayList<String>>>());
myMap.get("myKey").put(FirstAL, SecondAL);

// now while retriving I'm getting null instead of Arraylist
ArrayList<String> resultAL = myMap.get("myKey").get("a");

}


Thnx in Advance. Please help me to figure where did I went wrong?



asked 1 min ago

kevz

220





Aucun commentaire:

Enregistrer un commentaire