{"id":38239,"date":"2024-11-26T12:47:43","date_gmt":"2024-11-26T04:47:43","guid":{"rendered":"https:\/\/fwq.ai\/blog\/38239\/"},"modified":"2024-11-26T12:47:43","modified_gmt":"2024-11-26T04:47:43","slug":"java-%e4%ba%8c%e7%bb%b4%e6%95%b0%e7%bb%84%e6%80%8e%e4%b9%88%e8%b5%8b%e5%80%bc","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/38239\/","title":{"rendered":"java \u4e8c\u7ef4\u6570\u7ec4\u600e\u4e48\u8d4b\u503c"},"content":{"rendered":"<blockquote><p>\n  \u4e8c\u7ef4\u6570\u7ec4\u8d4b\u503c\u6b65\u9aa4\uff1a\u58f0\u660e\u5e76\u521d\u59cb\u5316\u4e8c\u7ef4\u6570\u7ec4\u3002\u4f7f\u7528\u5d4c\u5957\u5faa\u73af\u904d\u5386\u5404\u4e2a\u5143\u7d20\u3002\u6307\u5b9a\u884c\u548c\u5217\u7d22\u5f15\uff0c\u7ed9\u5bf9\u5e94\u4f4d\u7f6e\u5143\u7d20\u8d4b\u503c\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202411\/14\/2024111411244846566.jpg\" class=\"aligncenter\" title=\"java \u4e8c\u7ef4\u6570\u7ec4\u600e\u4e48\u8d4b\u503c\u63d2\u56fe\" alt=\"java \u4e8c\u7ef4\u6570\u7ec4\u600e\u4e48\u8d4b\u503c\u63d2\u56fe\" \/><\/p>\n<p><strong>\u4e8c\u7ef4\u6570\u7ec4\u7684\u8d4b\u503c<\/strong><\/p>\n<p><strong>\u5982\u4f55\u8d4b\u503c\uff1f<\/strong><\/p>\n<p>\u4e8c\u7ef4\u6570\u7ec4\u662f\u4e00\u79cd\u6570\u636e\u7ed3\u6784\uff0c\u5b83\u5b58\u50a8\u5143\u7d20\u6309\u7167\u884c\u548c\u5217\u7ec4\u7ec7\u3002\u8981\u7ed9\u4e8c\u7ef4\u6570\u7ec4\u8d4b\u503c\uff0c\u9700\u8981\u6307\u5b9a\u884c\u548c\u5217\u7d22\u5f15\uff0c\u7136\u540e\u5c06\u503c\u5206\u914d\u7ed9\u8be5\u4f4d\u7f6e\u3002<\/p>\n<p><strong>\u5177\u4f53\u8d4b\u503c\u6b65\u9aa4\uff1a<\/strong><\/p>\n<p><span>\u7acb\u5373\u5b66\u4e60<\/span>\u201c\u201d\uff1b<\/p>\n<ol>\n<li>\u58f0\u660e\u5e76\u521d\u59cb\u5316\u4e8c\u7ef4\u6570\u7ec4\uff1aint[][] arr = new int[row][col];<\/li>\n<li>\n<p>\u4f7f\u7528\u5d4c\u5957\u5faa\u73af\u904d\u5386\u5404\u4e2a\u5143\u7d20\uff1a<\/p>\n<pre>for (int i = 0; i &lt; row; i++) {\n for (int j = 0; j &lt; col; j++) {\n     \/\/ \u7ed9\u7b2c i \u884c\u7b2c j \u5217\u7684\u5143\u7d20\u8d4b\u503c\n     arr[i][j] = value;\n }\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/li>\n<\/ol>\n<p><strong>\u793a\u4f8b\uff1a<\/strong><\/p>\n<pre>int[][] arr = new int[3][4];\n\n\/\/ \u7ed9\u7b2c\u4e00\u884c\u8d4b\u503c\nfor (int i = 0; i &lt; arr[0].length; i++) {\n    arr[0][i] = i;\n}\n\n\/\/ \u7ed9\u7b2c\u4e8c\u884c\u8d4b\u503c\nfor (int i = 0; i &lt; arr[1].length; i++) {\n    arr[1][i] = i + 10;\n}\n\n\/\/ \u7ed9\u7b2c\u4e09\u884c\u8d4b\u503c\nfor (int i = 0; i &lt; arr[2].length; i++) {\n    arr[2][i] = i + 20;\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u7ed3\u679c\uff1a<\/strong><\/p>\n<pre>arr = [\n    [0, 1, 2, 3],\n    [10, 11, 12, 13],\n    [20, 21, 22, 23]\n]<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fjava \u4e8c\u7ef4\u6570\u7ec4\u600e\u4e48\u8d4b\u503c\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e8c\u7ef4\u6570\u7ec4\u8d4b\u503c\u6b65\u9aa4\uff1a\u58f0\u660e\u5e76\u521d\u59cb\u5316\u4e8c\u7ef4\u6570\u7ec4\u3002\u4f7f\u7528\u5d4c\u5957\u5faa\u73af\u904d\u5386\u5404\u4e2a\u5143\u7d20\u3002\u6307\u5b9a\u884c\u548c\u5217\u7d22\u5f15\uff0c\u7ed9\u5bf9\u5e94\u4f4d\u7f6e\u5143\u7d20\u8d4b\u503c\u3002 \u4e8c\u7ef4\u6570\u7ec4\u7684\u8d4b\u503c \u5982\u4f55\u8d4b\u503c\uff1f \u4e8c\u7ef4\u6570\u7ec4\u662f\u4e00\u79cd\u6570\u636e\u7ed3\u6784\uff0c\u5b83\u5b58\u50a8\u5143\u7d20\u6309\u7167\u884c\u548c\u5217\u7ec4\u7ec7\u3002\u8981\u7ed9\u4e8c\u7ef4\u6570\u7ec4\u8d4b\u503c\uff0c\u9700\u8981\u6307\u5b9a\u884c\u548c\u5217\u7d22\u5f15\uff0c\u7136\u540e\u5c06\u503c\u5206\u914d\u7ed9\u8be5\u4f4d\u7f6e\u3002 \u5177\u4f53\u8d4b\u503c\u6b65\u9aa4\uff1a \u7acb\u5373\u5b66\u4e60\u201c\u201d\uff1b \u58f0\u660e\u5e76\u521d\u59cb\u5316\u4e8c\u7ef4\u6570\u7ec4\uff1aint[][] arr = new int[row][col]; \u4f7f\u7528\u5d4c\u5957\u5faa\u73af\u904d\u5386\u5404\u4e2a\u5143\u7d20\uff1a for (int i = 0; i &lt; row; i++) { for (int j = 0; j &lt; col; j++) { \/\/ \u7ed9\u7b2c i \u884c\u7b2c j \u5217\u7684\u5143\u7d20\u8d4b\u503c arr[i][j] = value; } } \u767b\u5f55\u540e\u590d\u5236 \u793a\u4f8b\uff1a int[][] arr = new int[3][4]; \/\/ \u7ed9\u7b2c\u4e00\u884c\u8d4b\u503c for (int i [&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-38239","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/38239","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=38239"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/38239\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=38239"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=38239"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=38239"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}