How to retrieve values from nested hashmap?
843789Dec 8 2009 — edited Dec 9 2009Hi,
I am calling a Single view function, which returns a nested hash (hash map) structure.
Please help me with how to retrieve values from nested hashmap.
I have tried with below sample.
HashMap hashMap = new HashMap();
HashMap hashMap1 = new HashMap();
HashMap hashMap2 = new HashMap();
hashMap.put( "One", new Integer(1) );
hashMap.put( "Two", new Integer(2) );
hashMap.put( "Three", new Integer(3) );
hashMap1.put( "for", new Integer(4) );
hashMap1.put( "fiv", new Integer(5) );
hashMap.put( "hashMap1", hashMap1);
hashMap2 = (HashMap) hashMap.get(hashMap1);
System.out.println(hashMap2.get("fiv"));
I am getting NullPointerException.
Please suggest me how to proceed.
Thanks,
Ravi Sankara Sastry