{"id":65960,"date":"2025-05-03T11:12:25","date_gmt":"2025-05-03T03:12:25","guid":{"rendered":"https:\/\/fwq.ai\/blog\/65960\/"},"modified":"2025-05-03T11:12:25","modified_gmt":"2025-05-03T03:12:25","slug":"java%e6%80%8e%e4%b9%88%e5%90%8c%e6%97%b6%e8%be%93%e5%87%ba%e5%a4%9a%e4%b8%aa%e6%95%b0%e7%bb%84-2","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/65960\/","title":{"rendered":"java\u600e\u4e48\u540c\u65f6\u8f93\u51fa\u591a\u4e2a\u6570\u7ec4"},"content":{"rendered":"<blockquote><p>\n  \u6709\u591a\u79cd\u65b9\u6cd5\u53ef\u540c\u65f6\u8f93\u51fa\u591a\u4e2a\u6570\u7ec4\uff1a\u4f7f\u7528 system.out.print() \u548c system.out.println() \u4e3a\u6bcf\u4e2a\u6570\u7ec4\u5355\u72ec\u6253\u5370\u5143\u7d20\u3002\u4f7f\u7528 arrays.tostring() \u5c06\u6570\u7ec4\u8f6c\u6362\u4e3a\u5b57\u7b26\u4e32\u5e76\u6253\u5370\u3002\u4f7f\u7528 stream.concat() \u5c06\u6570\u7ec4\u8f6c\u6362\u4e3a\u6d41\u5e76\u5408\u5e76\uff0c\u7136\u540e\u8f6c\u6362\u4e3a\u5217\u8868\u5e76\u6253\u5370\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202411\/13\/2024111317221457669.jpg\" class=\"aligncenter\" title=\"java\u600e\u4e48\u540c\u65f6\u8f93\u51fa\u591a\u4e2a\u6570\u7ec4\u63d2\u56fe\" alt=\"java\u600e\u4e48\u540c\u65f6\u8f93\u51fa\u591a\u4e2a\u6570\u7ec4\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5982\u4f55\u540c\u65f6\u8f93\u51fa\u591a\u4e2a\u6570\u7ec4<\/strong><\/p>\n<p>\u5f53\u6211\u4eec\u9700\u8981\u540c\u65f6\u8f93\u51fa\u591a\u4e2a\u6570\u7ec4\u65f6\uff0c\u6709\u4ee5\u4e0b\u51e0\u79cd\u65b9\u6cd5\uff1a<\/p>\n<p><strong>1. \u4f7f\u7528 System.out.print() \u548c System.out.println()<\/strong><\/p>\n<pre>int[] arr1 = {1, 2, 3};\nint[] arr2 = {4, 5, 6};\n\nSystem.out.println(\"\u6570\u7ec41\uff1a\");\nfor (int i : arr1) {\n    System.out.print(i + \" \");\n}\n\nSystem.out.println(\"\n\u6570\u7ec42\uff1a\");\nfor (int i : arr2) {\n    System.out.print(i + \" \");\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u8f93\u51fa\uff1a<\/strong><\/p>\n<p><span>\u7acb\u5373\u5b66\u4e60<\/span>\u201c\u201d\uff1b<\/p>\n<pre>\u6570\u7ec41\uff1a\n1 2 3\n\u6570\u7ec42\uff1a\n4 5 6<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>2. \u4f7f\u7528 Arrays.toString()<\/strong><\/p>\n<pre>int[] arr1 = {1, 2, 3};\nint[] arr2 = {4, 5, 6};\n\nSystem.out.println(\"\u6570\u7ec41\uff1a\" + Arrays.toString(arr1));\nSystem.out.println(\"\u6570\u7ec42\uff1a\" + Arrays.toString(arr2));<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u8f93\u51fa\uff1a<\/strong><\/p>\n<p><span>\u7acb\u5373\u5b66\u4e60<\/span>\u201c\u201d\uff1b<\/p>\n<pre>\u6570\u7ec41\uff1a[1, 2, 3]\n\u6570\u7ec42\uff1a[4, 5, 6]<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>3. \u4f7f\u7528 Stream.concat()<\/strong><\/p>\n<pre>int[] arr1 = {1, 2, 3};\nint[] arr2 = {4, 5, 6};\n\nList&lt;Integer&gt; combinedList = Stream.concat(Arrays.stream(arr1), Arrays.stream(arr2)).toList();\nSystem.out.println(combinedList);<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u8f93\u51fa\uff1a<\/strong><\/p>\n<p><span>\u7acb\u5373\u5b66\u4e60<\/span>\u201c\u201d\uff1b<\/p>\n<pre>[1, 2, 3, 4, 5, 6]<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fjava\u600e\u4e48\u540c\u65f6\u8f93\u51fa\u591a\u4e2a\u6570\u7ec4\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8IDCBABY\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6709\u591a\u79cd\u65b9\u6cd5\u53ef\u540c\u65f6\u8f93\u51fa\u591a\u4e2a\u6570\u7ec4\uff1a\u4f7f\u7528 system.out.print() \u548c system.out.println() \u4e3a\u6bcf\u4e2a\u6570\u7ec4\u5355\u72ec\u6253\u5370\u5143\u7d20\u3002\u4f7f\u7528 arrays.tostring() \u5c06\u6570\u7ec4\u8f6c\u6362\u4e3a\u5b57\u7b26\u4e32\u5e76\u6253\u5370\u3002\u4f7f\u7528 stream.concat() \u5c06\u6570\u7ec4\u8f6c\u6362\u4e3a\u6d41\u5e76\u5408\u5e76\uff0c\u7136\u540e\u8f6c\u6362\u4e3a\u5217\u8868\u5e76\u6253\u5370\u3002 \u5982\u4f55\u540c\u65f6\u8f93\u51fa\u591a\u4e2a\u6570\u7ec4 \u5f53\u6211\u4eec\u9700\u8981\u540c\u65f6\u8f93\u51fa\u591a\u4e2a\u6570\u7ec4\u65f6\uff0c\u6709\u4ee5\u4e0b\u51e0\u79cd\u65b9\u6cd5\uff1a 1. \u4f7f\u7528 System.out.print() \u548c System.out.println() int[] arr1 = {1, 2, 3}; int[] arr2 = {4, 5, 6}; System.out.println(&#8220;\u6570\u7ec41\uff1a&#8221;); for (int i : arr1) { System.out.print(i + &#8221; &#8220;); } System.out.println(&#8221; \u6570\u7ec42\uff1a&#8221;); for (int i : arr2) { System.out.print(i + &#8221; &#8220;); } \u767b\u5f55\u540e\u590d\u5236 \u8f93\u51fa\uff1a [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-65960","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/65960","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=65960"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/65960\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=65960"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=65960"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=65960"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}