list< map< String, string>> Open map< String, list< String>>

Source: Internet
Author: User

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 = (); 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&lt; map&lt; String, string&gt;&gt; Open map&lt; String, list&lt; String&gt;&gt;

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.