The list becomes a map structure, the following text is no level!
The writing method transmits the soil for a long time before it is transmitted. I don't know if there is any good solution. We also want to offer!
map<string, string> map1 = new hashmap<string, string> (), Map1.put ("A", "1"), Map1.put ("B", "3"), Map1.put ("C "," 5 "); map<string, string> map2 = new hashmap<string, string> (), Map2.put ("A", "2"), Map2.put ("B", "4"), Map2.put ("C "," 6 "); list<map<string, string>> lm = new arraylist<map<string, string>> (); Lm.add (MAP1); Lm.add (map2 ); map<string, list<string>> ml = new hashmap<string, list<string>> (); for (int i = 0; i < lm.size ( ); i++) {map<string, string> m = Lm.get (i); iterator<map.entry<string, string>> it = M.entrySet (). Iterator (); while (It.hasnext ()) {map.entry<string, string> Entry = It.next (); List<string> al = Ml.get (Entry.getkey ()); if (Al = = null) {Al = new arraylist<string> ();} Al.add (Entry.getvalue ()); Ml.put (Entry.getkey (), AL);}} SYSTEM.OUT.PRINTLN (ml);//{b=[3, 4], c=[5, 6], a=[1, 2]}
Copyright notice: This article Bo Master original articles, blogs, without consent may not be reproduced.
list< map< String, string>> Open map< String, list< String>>