Public classTest { Public Static voidMain (string[] args) {List<map<string, object>> listmaps =NewArraylist<map<string, object>>(); Map<string, object> map1 =NewHashmap<string, object>(); Map1.put ("1", "a"); Map1.put ("2", "B"); Map1.put ("3", "C"); Listmaps.add (MAP1); Map<string, object> map2 =NewHashmap<string, object>(); Map2.put ("One", "AA"); Map2.put ("A", "BB"); Map2.put ("", "CC"); Listmaps.add (MAP2); for(Map<string, object>map:listmaps) { for(String s:map.keyset ()) {System.out.print (Map.get (s)+ " "); }} System.out.println (); System.out.println ("========================"); for(inti = 0; I < listmaps.size (); i++) {Map<string, object> map =Listmaps.get (i); Iterator Iterator=Map.keyset (). iterator (); while(Iterator.hasnext ()) {string string=(String) iterator.next (); System.out.println (Map.get (string)); }} System.out.println ("++++++++++++++++++++++++++++"); for(Map<string, object>map:listmaps) { for(Map.entry<string, object>M:map.entryset ()) {System.out.print (M.getkey ()+ " "); System.out.println (M.getvalue ()); }} System.out.println ("-----------------------------"); }} Results printed: c b a BB cc AA========================CBABBCCAA++++++++++++++++++++++++++++c B a BB cc AA-----------------------------
Methods of Java list<map<string,object> traversal