{"id":39652,"date":"2024-11-26T17:13:47","date_gmt":"2024-11-26T09:13:47","guid":{"rendered":"https:\/\/fwq.ai\/blog\/39652\/"},"modified":"2024-11-26T17:13:47","modified_gmt":"2024-11-26T09:13:47","slug":"java%e6%80%8e%e4%b9%88%e7%bb%99%e4%ba%8c%e7%bb%b4%e6%95%b0%e7%bb%84%e7%9a%84%e6%af%8f%e4%b8%aa%e4%b8%80%e7%bb%b4%e6%95%b0%e7%bb%84%e8%b5%8b%e5%80%bc","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/39652\/","title":{"rendered":"java\u600e\u4e48\u7ed9\u4e8c\u7ef4\u6570\u7ec4\u7684\u6bcf\u4e2a\u4e00\u7ef4\u6570\u7ec4\u8d4b\u503c"},"content":{"rendered":"<blockquote><p>\n  \u8981\u7ed9 java \u4e8c\u7ef4\u6570\u7ec4\u7684\u6bcf\u4e2a\u4e00\u7ef4\u6570\u7ec4\u8d4b\u503c\uff0c\u53ef\u4ee5\u4f7f\u7528\u5d4c\u5957\u5faa\u73af\uff1a\u521b\u5efa\u4e8c\u7ef4\u6570\u7ec4\uff1b\u4f7f\u7528\u5916\u5c42\u5faa\u73af\u904d\u5386\u884c\uff1b\u4f7f\u7528\u5185\u5c42\u5faa\u73af\u904d\u5386\u5217\uff0c\u5e76\u4e3a\u6bcf\u4e2a\u5355\u5143\u683c\u8d4b\u503c\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202411\/16\/2024111620122143466.jpg\" class=\"aligncenter\" title=\"java\u600e\u4e48\u7ed9\u4e8c\u7ef4\u6570\u7ec4\u7684\u6bcf\u4e2a\u4e00\u7ef4\u6570\u7ec4\u8d4b\u503c\u63d2\u56fe\" alt=\"java\u600e\u4e48\u7ed9\u4e8c\u7ef4\u6570\u7ec4\u7684\u6bcf\u4e2a\u4e00\u7ef4\u6570\u7ec4\u8d4b\u503c\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5982\u4f55\u7ed9 Java \u4e8c\u7ef4\u6570\u7ec4\u7684\u6bcf\u4e2a\u4e00\u7ef4\u6570\u7ec4\u8d4b\u503c<\/strong><\/p>\n<p><strong>\u89e3\u7b54\uff1a<\/strong><\/p>\n<p>\u7ed9\u4e8c\u7ef4\u6570\u7ec4\u7684\u6bcf\u4e2a\u4e00\u7ef4\u6570\u7ec4\u8d4b\u503c\u53ef\u4ee5\u901a\u8fc7\u4f7f\u7528\u5d4c\u5957\u5faa\u73af\u3002<\/p>\n<p><strong>\u6b65\u9aa4\uff1a<\/strong><\/p>\n<p><span>\u7acb\u5373\u5b66\u4e60<\/span>\u201c\u201d\uff1b<\/p>\n<ol>\n<li>\n<p>\u521b\u5efa\u4e00\u4e2a\u4e8c\u7ef4\u6570\u7ec4\uff1a<\/p>\n<pre>int[][] arr = new int[rows][cols];<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/li>\n<li>\n<p>\u4f7f\u7528\u5916\u5c42\u5faa\u73af\u904d\u5386\u884c\uff1a<\/p>\n<pre>for (int i = 0; i &lt; rows; i++) {<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/li>\n<li>\n<p>\u4f7f\u7528\u5185\u5c42\u5faa\u73af\u904d\u5386\u5217\uff0c\u5e76\u4e3a\u6bcf\u4e2a\u5355\u5143\u683c\u8d4b\u503c\uff1a<\/p>\n<pre> for (int j = 0; j &lt; cols; j++) {\n     arr[i][j] = value;\n }\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/li>\n<\/ol>\n<p>\u5176\u4e2d\uff0c<strong>rows<\/strong> \u662f\u4e8c\u7ef4\u6570\u7ec4\u7684\u884c\u6570\uff0c<strong>cols<\/strong> \u662f\u4e8c\u7ef4\u6570\u7ec4\u7684\u5217\u6570\uff0c<strong>value<\/strong> \u662f\u8981\u8d4b\u7ed9\u5355\u5143\u683c\u7684\u503c\u3002<\/p>\n<p><strong>\u4ee3\u7801\u793a\u4f8b\uff1a<\/strong><\/p>\n<pre>int[][] arr = new int[3][4];\n\n\/\/ \u7ed9\u7b2c\u4e8c\u884c\u8d4b\u503c\nfor (int i = 1; i &lt; rows; i++) {\n    for (int j = 0; j &lt; cols; j++) {\n        arr[i][j] = 10;\n    }\n}\n\n\/\/ \u6253\u5370\u4e8c\u7ef4\u6570\u7ec4\nfor (int[] row : arr) {\n    for (int col : row) {\n        System.out.print(col + \" \");\n    }\n    System.out.println();\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u8f93\u51fa\uff1a<\/strong><\/p>\n<pre>0 0 0 0\n10 10 10 10\n0 0 0 0<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fjava\u600e\u4e48\u7ed9\u4e8c\u7ef4\u6570\u7ec4\u7684\u6bcf\u4e2a\u4e00\u7ef4\u6570\u7ec4\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>\u8981\u7ed9 java \u4e8c\u7ef4\u6570\u7ec4\u7684\u6bcf\u4e2a\u4e00\u7ef4\u6570\u7ec4\u8d4b\u503c\uff0c\u53ef\u4ee5\u4f7f\u7528\u5d4c\u5957\u5faa\u73af\uff1a\u521b\u5efa\u4e8c\u7ef4\u6570\u7ec4\uff1b\u4f7f\u7528\u5916\u5c42\u5faa\u73af\u904d\u5386\u884c\uff1b\u4f7f\u7528\u5185\u5c42\u5faa\u73af\u904d\u5386\u5217\uff0c\u5e76\u4e3a\u6bcf\u4e2a\u5355\u5143\u683c\u8d4b\u503c\u3002 \u5982\u4f55\u7ed9 Java \u4e8c\u7ef4\u6570\u7ec4\u7684\u6bcf\u4e2a\u4e00\u7ef4\u6570\u7ec4\u8d4b\u503c \u89e3\u7b54\uff1a \u7ed9\u4e8c\u7ef4\u6570\u7ec4\u7684\u6bcf\u4e2a\u4e00\u7ef4\u6570\u7ec4\u8d4b\u503c\u53ef\u4ee5\u901a\u8fc7\u4f7f\u7528\u5d4c\u5957\u5faa\u73af\u3002 \u6b65\u9aa4\uff1a \u7acb\u5373\u5b66\u4e60\u201c\u201d\uff1b \u521b\u5efa\u4e00\u4e2a\u4e8c\u7ef4\u6570\u7ec4\uff1a int[][] arr = new int[rows][cols]; \u767b\u5f55\u540e\u590d\u5236 \u4f7f\u7528\u5916\u5c42\u5faa\u73af\u904d\u5386\u884c\uff1a for (int i = 0; i &lt; rows; i++) { \u767b\u5f55\u540e\u590d\u5236 \u4f7f\u7528\u5185\u5c42\u5faa\u73af\u904d\u5386\u5217\uff0c\u5e76\u4e3a\u6bcf\u4e2a\u5355\u5143\u683c\u8d4b\u503c\uff1a for (int j = 0; j &lt; cols; j++) { arr[i][j] = value; } } \u767b\u5f55\u540e\u590d\u5236 \u5176\u4e2d\uff0crows \u662f\u4e8c\u7ef4\u6570\u7ec4\u7684\u884c\u6570\uff0ccols \u662f\u4e8c\u7ef4\u6570\u7ec4\u7684\u5217\u6570\uff0cvalue \u662f\u8981\u8d4b\u7ed9\u5355\u5143\u683c\u7684\u503c\u3002 \u4ee3\u7801\u793a\u4f8b\uff1a int[][] arr = new [&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-39652","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/39652","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=39652"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/39652\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=39652"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=39652"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=39652"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}