{"id":3846,"date":"2024-08-14T12:57:10","date_gmt":"2024-08-14T04:57:10","guid":{"rendered":"https:\/\/qaqaq.top\/?p=3846"},"modified":"2024-08-14T12:57:10","modified_gmt":"2024-08-14T04:57:10","slug":"list%e4%b8%ad%e5%a2%9e%e5%8a%a0%e7%9a%84put%e6%9b%b4%e6%96%b0%e8%bf%87%e7%9a%84map%e7%9a%84%e5%80%bc%e6%98%af%e7%9b%b8%e5%90%8c%e7%9a%84","status":"publish","type":"post","link":"https:\/\/qaqaq.top\/?p=3846","title":{"rendered":"list\u4e2d\u589e\u52a0\u7684put\u66f4\u65b0\u8fc7\u7684map\u7684\u503c\u662f\u76f8\u540c\u7684"},"content":{"rendered":"\n<h6 class=\"wp-block-heading\">\u4ee3\u7801<\/h6>\n\n\n\n<pre class=\"wp-block-preformatted\"> &nbsp; &nbsp;public static void main(String[] args) {<br>\u200b<br> &nbsp; &nbsp; &nbsp; &nbsp;test test = new test();<br>\u200b<br> &nbsp; &nbsp; &nbsp; &nbsp;test.bugOne();<br>\u200b<br> &nbsp;  }<br>\u200b<br> &nbsp; &nbsp;private void bugOne() {<br>\u200b<br> &nbsp; &nbsp; &nbsp; &nbsp;List&lt;Map&lt;String, Object&gt;&gt; list = new ArrayList&lt;&gt;();<br> &nbsp; &nbsp; &nbsp; &nbsp;HashMap&lt;String, Object&gt; map = new HashMap&lt;&gt;();<br>\u200b<br> &nbsp; &nbsp; &nbsp; &nbsp;map.put(\"1\", \"1\");<br> &nbsp; &nbsp; &nbsp; &nbsp;map.put(\"2\", \"2\");<br> &nbsp; &nbsp; &nbsp; &nbsp;map.put(\"3\", \"3\");<br> &nbsp; &nbsp; &nbsp; &nbsp;map.put(\"4\", \"4\");<br> &nbsp; &nbsp; &nbsp; &nbsp;list.add(map);<br>\u200b<br> &nbsp; &nbsp; &nbsp; &nbsp;System.out.println(list);<br>\u200b<br> &nbsp; &nbsp; &nbsp; &nbsp;for (int i = 0; i &lt; 2; i++) {<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;map.put(\"1\", \"11\" + i);<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;map.put(\"2\", \"22\" + i);<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;map.put(\"3\", \"33\" + i);<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;map.put(\"4\", \"44\" + i);<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;list.add(map);<br> &nbsp; &nbsp; &nbsp;  }<br>\u200b<br> &nbsp; &nbsp; &nbsp; &nbsp;System.out.println(list);<br> &nbsp; &nbsp; &nbsp; &nbsp;<br> &nbsp;  }<\/pre>\n\n\n\n<h6 class=\"wp-block-heading\">\u7ed3\u679c<\/h6>\n\n\n\n<figure class=\"wp-block-image size-large\"><div class='fancybox-wrapper lazyload-container-unload' data-fancybox='post-images' href='https:\/\/qaqaq.top\/wp-content\/uploads\/2024\/08\/image-20240814112658697-1024x201.png'><img class=\"lazyload lazyload-style-1\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"201\" data-original=\"https:\/\/qaqaq.top\/wp-content\/uploads\/2024\/08\/image-20240814112658697-1024x201.png\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" alt=\"\" class=\"wp-image-3847\"  sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/div><\/figure>\n\n\n\n<h6 class=\"wp-block-heading\">\u539f\u56e0<\/h6>\n\n\n\n<p>\u5728 Java \u4e2d\uff0c\u200c\u5982\u679c\u5c06\u76f8\u540c\u7684 Map \u5bf9\u8c61\u591a\u6b21\u6dfb\u52a0\u5230 Lis t\u96c6\u5408\u4e2d\uff0c\u200c\u5219\u5728 List \u96c6\u5408\u4e2d\u5b58\u50a8\u7684 Map \u5bf9\u8c61\u5b9e\u9645\u4e0a\u662f\u540c\u4e00\u4e2a\u5bf9\u8c61\u3002<\/p>\n\n\n\n<p>\u8fd9\u662f\u56e0\u4e3a\u5728 Java \u4e2d\uff0c\u901a\u8fc7\u53d8\u91cf\u548c\u96c6\u5408\u4e2d\u4fdd\u5b58\u7684\u662f\u5bf9\u8c61\u7684\u5f15\u7528\uff0c\u200c\u800c\u4e0d\u662f\u5bf9\u8c61\u672c\u8eab\u7684\u62f7\u8d1d\u3002\u200c<\/p>\n\n\n\n<p>\u5f53\u4f7f\u7528\u76f8\u540c\u7684\u5bf9\u8c61\u4f5c\u4e3a\u53c2\u6570\u591a\u6b21\u8c03\u7528\u65b9\u6cd5\u65f6\uff0c\u200c\u5b9e\u9645\u4e0a\u662f\u591a\u6b21\u4f7f\u7528\u4e86\u540c\u4e00\u4e2a\u5bf9\u8c61\u3002\u200c<\/p>\n\n\n\n<p>\u56e0\u6b64\uff0c\u200c\u5982\u679c\u66f4\u6539\u5176\u4e2d\u4e00\u4e2a Map \u5bf9\u8c61\u7684\u503c\uff0c\u200c\u6240\u6709\u5728 List \u96c6\u5408\u4e2d\u5b58\u50a8\u7684 Map \u5bf9\u8c61\u90fd\u5c06\u53cd\u6620\u8fd9\u4e9b\u66f4\u6539\uff0c\u56e0\u4e3a\u5b83\u4eec\u5b9e\u9645\u4e0a\u662f\u540c\u4e00\u4e2a\u5bf9\u8c61\u3002\u200c<\/p>\n\n\n\n<h6 class=\"wp-block-heading\">\u89e3\u51b3<\/h6>\n\n\n\n<p>\u91cd\u65b0 New \u4e00\u4e2a\u65b0\u7684 Map \u5bf9\u8c61\u7528\u6765\u5b58\u50a8\u6570\u636e<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"> &nbsp; &nbsp;public static void main(String[] args) {<br>\u200b<br> &nbsp; &nbsp; &nbsp; &nbsp;test test = new test();<br>\u200b<br> &nbsp; &nbsp; &nbsp; &nbsp;test.bugOne();<br>\u200b<br> &nbsp;  }<br>\u200b<br> &nbsp; &nbsp;private void bugOne() {<br>\u200b<br> &nbsp; &nbsp; &nbsp; &nbsp;List&lt;Map&lt;String, Object&gt;&gt; list = new ArrayList&lt;&gt;();<br> &nbsp; &nbsp; &nbsp; &nbsp;HashMap&lt;String, Object&gt; map = new HashMap&lt;&gt;();<br>\u200b<br> &nbsp; &nbsp; &nbsp; &nbsp;map.put(\"1\", \"1\");<br> &nbsp; &nbsp; &nbsp; &nbsp;map.put(\"2\", \"2\");<br> &nbsp; &nbsp; &nbsp; &nbsp;map.put(\"3\", \"3\");<br> &nbsp; &nbsp; &nbsp; &nbsp;map.put(\"4\", \"4\");<br> &nbsp; &nbsp; &nbsp; &nbsp;list.add(map);<br>\u200b<br> &nbsp; &nbsp; &nbsp; &nbsp;System.out.println(list);<br>\u200b<br>\/\/ &nbsp; &nbsp; &nbsp;  for (int i = 0; i &lt; 2; i++) {<br>\/\/ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  map.put(\"1\", \"11\" + i);<br>\/\/ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  map.put(\"2\", \"22\" + i);<br>\/\/ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  map.put(\"3\", \"33\" + i);<br>\/\/ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  map.put(\"4\", \"44\" + i);<br>\/\/ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  list.add(map);<br>\/\/ &nbsp; &nbsp; &nbsp;  }<br>\u200b<br> &nbsp; &nbsp; &nbsp; &nbsp;for (int i = 0; i &lt; 2; i++) {<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Map&lt;String, Object&gt; iMap = new HashMap&lt;&gt;();<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;iMap.put(\"1\", \"11\" + i);<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;iMap.put(\"2\", \"22\" + i);<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;iMap.put(\"3\", \"33\" + i);<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;iMap.put(\"4\", \"44\" + i);<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;list.add(iMap);<br> &nbsp; &nbsp; &nbsp;  }<br>\u200b<br> &nbsp; &nbsp; &nbsp; &nbsp;System.out.println(list);<br> &nbsp; &nbsp; &nbsp; &nbsp;<br> &nbsp;  }<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u4ee3\u7801 &nbsp; &nbsp;public static void main(String[] args)  [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[29],"tags":[46],"class_list":["post-3846","post","type-post","status-publish","format-standard","hentry","category-java-","tag-java"],"_links":{"self":[{"href":"https:\/\/qaqaq.top\/index.php?rest_route=\/wp\/v2\/posts\/3846"}],"collection":[{"href":"https:\/\/qaqaq.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/qaqaq.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/qaqaq.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/qaqaq.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3846"}],"version-history":[{"count":1,"href":"https:\/\/qaqaq.top\/index.php?rest_route=\/wp\/v2\/posts\/3846\/revisions"}],"predecessor-version":[{"id":3848,"href":"https:\/\/qaqaq.top\/index.php?rest_route=\/wp\/v2\/posts\/3846\/revisions\/3848"}],"wp:attachment":[{"href":"https:\/\/qaqaq.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3846"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/qaqaq.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3846"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/qaqaq.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3846"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}