{"id":66314,"date":"2025-05-03T16:08:23","date_gmt":"2025-05-03T08:08:23","guid":{"rendered":"https:\/\/fwq.ai\/blog\/66314\/"},"modified":"2025-05-03T16:08:23","modified_gmt":"2025-05-03T08:08:23","slug":"java%e4%b8%ad%e4%ba%8c%e7%bb%b4%e6%95%b0%e7%bb%84%e6%80%8e%e4%b9%88%e6%89%93%e5%8d%b0-2","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/66314\/","title":{"rendered":"java\u4e2d\u4e8c\u7ef4\u6570\u7ec4\u600e\u4e48\u6253\u5370"},"content":{"rendered":"<blockquote><p>\n  \u5728 java \u4e2d\u6253\u5370\u4e8c\u7ef4\u6570\u7ec4\u6709\u4e24\u79cd\u4e3b\u8981\u65b9\u6cd5\uff1a\u5d4c\u5957\u5faa\u73af\uff1a\u4f7f\u7528\u4e24\u4e2a\u5d4c\u5957\u5faa\u73af\u904d\u5386\u6570\u7ec4\uff0c\u5bf9\u4e8e\u6bcf\u4e2a\u884c\u548c\u5217\u6253\u5370\u5143\u7d20\u3002arrays.tostring()\uff1a\u4f7f\u7528 arrays.tostring() \u5c06\u4e8c\u7ef4\u6570\u7ec4\u8f6c\u6362\u4e3a\u5b57\u7b26\u4e32\uff0c\u7136\u540e\u8fde\u63a5\u6bcf\u4e00\u884c\u7684\u5b57\u7b26\u4e32\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202411\/15\/2024111507005148814.jpg\" class=\"aligncenter\" title=\"java\u4e2d\u4e8c\u7ef4\u6570\u7ec4\u600e\u4e48\u6253\u5370\u63d2\u56fe\" alt=\"java\u4e2d\u4e8c\u7ef4\u6570\u7ec4\u600e\u4e48\u6253\u5370\u63d2\u56fe\" \/><\/p>\n<p><strong>Java\u4e2d\u4e8c\u7ef4\u6570\u7ec4\u7684\u6253\u5370<\/strong><\/p>\n<p>\u6253\u5370\u4e8c\u7ef4\u6570\u7ec4\u6709\u4e24\u79cd\u4e3b\u8981\u65b9\u6cd5\uff1a<\/p>\n<p><strong>1. \u5d4c\u5957\u5faa\u73af<\/strong><\/p>\n<ul>\n<li>\u4f7f\u7528\u4e24\u4e2a\u5d4c\u5957\u5faa\u73af\u904d\u5386\u6570\u7ec4\u7684\u6bcf\u4e00\u884c\u548c\u6bcf\u4e00\u5217\u3002<\/li>\n<li>\u5bf9\u4e8e\u6bcf\u4e00\u5bf9\u884c\u53f7\u548c\u5217\u53f7\uff0c\u6253\u5370\u6570\u7ec4\u4e2d\u76f8\u5e94\u7684\u5143\u7d20\u3002<\/li>\n<\/ul>\n<pre>int[][] arr = {{1, 2, 3}, {4, 5, 6}};\n\nfor (int i = 0; i &lt; arr.length; i++) {\n    for (int j = 0; j &lt; arr[i].length; j++) {\n        System.out.print(arr[i][j] + \" \");\n    }\n    System.out.println();\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>1 2 3 \n4 5 6 <\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>2. \u4f7f\u7528Arrays.toString()<\/strong><\/p>\n<ul>\n<li>\u4f7f\u7528Arrays.toString()\u65b9\u6cd5\u5c06\u4e8c\u7ef4\u6570\u7ec4\u8f6c\u6362\u4e3a\u5b57\u7b26\u4e32\u3002<\/li>\n<li>\u5bf9\u4e8e\u6bcf\u4e00\u884c\uff0cArrays.toString(arr[i])\u5c06\u4ea7\u751f\u4e00\u4e2a\u8868\u793a\u8be5\u884c\u7684\u5b57\u7b26\u4e32\u3002<\/li>\n<li>\u5c06\u8fd9\u4e9b\u5b57\u7b26\u4e32\u8fde\u63a5\u8d77\u6765\u4ee5\u83b7\u53d6\u6574\u4e2a\u4e8c\u7ef4\u6570\u7ec4\u7684\u8868\u793a\u3002<\/li>\n<\/ul>\n<pre>int[][] arr = {{1, 2, 3}, {4, 5, 6}};\n\nString[][] strArr = Arrays.stream(arr)\n        .map(Arrays::toString)\n        .toArray(String[][]::new);\n\nSystem.out.println(Arrays.deepToString(strArr));<\/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\u4e2d\u4e8c\u7ef4\u6570\u7ec4\u600e\u4e48\u6253\u5370\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>\u5728 java \u4e2d\u6253\u5370\u4e8c\u7ef4\u6570\u7ec4\u6709\u4e24\u79cd\u4e3b\u8981\u65b9\u6cd5\uff1a\u5d4c\u5957\u5faa\u73af\uff1a\u4f7f\u7528\u4e24\u4e2a\u5d4c\u5957\u5faa\u73af\u904d\u5386\u6570\u7ec4\uff0c\u5bf9\u4e8e\u6bcf\u4e2a\u884c\u548c\u5217\u6253\u5370\u5143\u7d20\u3002arrays.tostring()\uff1a\u4f7f\u7528 arrays.tostring() \u5c06\u4e8c\u7ef4\u6570\u7ec4\u8f6c\u6362\u4e3a\u5b57\u7b26\u4e32\uff0c\u7136\u540e\u8fde\u63a5\u6bcf\u4e00\u884c\u7684\u5b57\u7b26\u4e32\u3002 Java\u4e2d\u4e8c\u7ef4\u6570\u7ec4\u7684\u6253\u5370 \u6253\u5370\u4e8c\u7ef4\u6570\u7ec4\u6709\u4e24\u79cd\u4e3b\u8981\u65b9\u6cd5\uff1a 1. \u5d4c\u5957\u5faa\u73af \u4f7f\u7528\u4e24\u4e2a\u5d4c\u5957\u5faa\u73af\u904d\u5386\u6570\u7ec4\u7684\u6bcf\u4e00\u884c\u548c\u6bcf\u4e00\u5217\u3002 \u5bf9\u4e8e\u6bcf\u4e00\u5bf9\u884c\u53f7\u548c\u5217\u53f7\uff0c\u6253\u5370\u6570\u7ec4\u4e2d\u76f8\u5e94\u7684\u5143\u7d20\u3002 int[][] arr = {{1, 2, 3}, {4, 5, 6}}; for (int i = 0; i &lt; arr.length; i++) { for (int j = 0; j &lt; arr[i].length; j++) { System.out.print(arr[i][j] + &#8221; &#8220;); } System.out.println(); } \u767b\u5f55\u540e\u590d\u5236 \u8f93\u51fa\uff1a \u7acb\u5373\u5b66\u4e60\u201c\u201d\uff1b 1 2 3 4 5 [&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-66314","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/66314","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=66314"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/66314\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=66314"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=66314"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=66314"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}