{"id":39953,"date":"2024-11-26T09:22:48","date_gmt":"2024-11-26T01:22:48","guid":{"rendered":"https:\/\/fwq.ai\/blog\/39953\/"},"modified":"2024-11-26T09:22:48","modified_gmt":"2024-11-26T01:22:48","slug":"java%e4%b8%ad%e7%9a%84%e4%ba%8c%e7%bb%b4%e6%95%b0%e7%bb%84%e6%80%8e%e4%b9%88%e7%9c%8b","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/39953\/","title":{"rendered":"JAVA\u4e2d\u7684\u4e8c\u7ef4\u6570\u7ec4\u600e\u4e48\u770b"},"content":{"rendered":"<blockquote><p>\n  \u4e8c\u7ef4\u6570\u7ec4\u5728 java \u4e2d\u8868\u793a\u4e3a\u4e00\u4e2a\u77e9\u5f62\u8868\u683c\uff0c\u5176\u4e2d\u6bcf\u4e2a\u5143\u7d20\u7531\u884c\u548c\u5217\u7d22\u5f15\u6807\u8bc6\u3002\u8bfb\u53d6\u5143\u7d20\u65f6\uff0c\u4f7f\u7528 arrayrow \u8bed\u6cd5\uff0c\u800c\u5199\u5165\u5143\u7d20\u65f6\uff0c\u4f7f\u7528 arrayrow = value\u3002\u8fed\u4ee3\u4e8c\u7ef4\u6570\u7ec4\u53ef\u4ee5\u901a\u8fc7\u5d4c\u5957\u5faa\u73af\u6216\u589e\u5f3a for \u5faa\u73af\u5b9e\u73b0\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202411\/17\/2024111714001831031.jpg\" class=\"aligncenter\" title=\"JAVA\u4e2d\u7684\u4e8c\u7ef4\u6570\u7ec4\u600e\u4e48\u770b\u63d2\u56fe\" alt=\"JAVA\u4e2d\u7684\u4e8c\u7ef4\u6570\u7ec4\u600e\u4e48\u770b\u63d2\u56fe\" \/><\/p>\n<p><strong>JAVA\u4e2d\u4e8c\u7ef4\u6570\u7ec4\u7684\u8bfb\u5199<\/strong><\/p>\n<p>\u5728JAVA\u4e2d\uff0c\u4e8c\u7ef4\u6570\u7ec4\u662f\u4e00\u4e2a\u5b58\u50a8\u76f8\u540c\u6570\u636e\u7c7b\u578b\u7684\u5143\u7d20\u7684\u77e9\u5f62\u8868\u683c\u3002\u6bcf\u4e2a\u5143\u7d20\u7531\u5176\u884c\u548c\u5217\u7d22\u5f15\u552f\u4e00\u6807\u8bc6\u3002<\/p>\n<p><strong>\u8bfb\u53d6\u4e8c\u7ef4\u6570\u7ec4\u5143\u7d20<\/strong><\/p>\n<pre>int[][] array = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};\n\n\/\/ \u8bbf\u95ee\u7b2c\u4e00\u884c\u7b2c\u4e00\u5217\u7684\u5143\u7d20\nint value1 = array[0][0]; \/\/ value1 = 1\n\n\/\/ \u8bbf\u95ee\u6700\u540e\u4e00\u884c\u6700\u540e\u4e00\u5217\u7684\u5143\u7d20\nint value2 = array[array.length - 1][array[0].length - 1]; \/\/ value2 = 9<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u5199\u5165\u4e8c\u7ef4\u6570\u7ec4\u5143\u7d20<\/strong><\/p>\n<p><span>\u7acb\u5373\u5b66\u4e60<\/span>\u201c\u201d\uff1b<\/p>\n<pre>int[][] array = new int[3][3];\n\n\/\/ \u8bbe\u7f6e\u7b2c\u4e00\u884c\u7b2c\u4e00\u5217\u7684\u5143\u7d20\narray[0][0] = 1;\n\n\/\/ \u8bbe\u7f6e\u6700\u540e\u4e00\u884c\u6700\u540e\u4e00\u5217\u7684\u5143\u7d20\narray[array.length - 1][array[0].length - 1] = 9;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u5faa\u73af\u904d\u5386\u4e8c\u7ef4\u6570\u7ec4<\/strong><\/p>\n<p><strong>\u5d4c\u5957\u5faa\u73af\uff1a<\/strong><\/p>\n<pre>for (int i = 0; i &lt; array.length; i++) {\n    for (int j = 0; j &lt; array[i].length; j++) {\n        \/\/ \u5904\u7406 array[i][j]\n    }\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u589e\u5f3a for \u5faa\u73af\uff1a<\/strong><\/p>\n<pre>for (int[] row : array) {\n    for (int element : row) {\n        \/\/ \u5904\u7406 element\n    }\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fJAVA\u4e2d\u7684\u4e8c\u7ef4\u6570\u7ec4\u600e\u4e48\u770b\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\u5728 java \u4e2d\u8868\u793a\u4e3a\u4e00\u4e2a\u77e9\u5f62\u8868\u683c\uff0c\u5176\u4e2d\u6bcf\u4e2a\u5143\u7d20\u7531\u884c\u548c\u5217\u7d22\u5f15\u6807\u8bc6\u3002\u8bfb\u53d6\u5143\u7d20\u65f6\uff0c\u4f7f\u7528 arrayrow \u8bed\u6cd5\uff0c\u800c\u5199\u5165\u5143\u7d20\u65f6\uff0c\u4f7f\u7528 arrayrow = value\u3002\u8fed\u4ee3\u4e8c\u7ef4\u6570\u7ec4\u53ef\u4ee5\u901a\u8fc7\u5d4c\u5957\u5faa\u73af\u6216\u589e\u5f3a for \u5faa\u73af\u5b9e\u73b0\u3002 JAVA\u4e2d\u4e8c\u7ef4\u6570\u7ec4\u7684\u8bfb\u5199 \u5728JAVA\u4e2d\uff0c\u4e8c\u7ef4\u6570\u7ec4\u662f\u4e00\u4e2a\u5b58\u50a8\u76f8\u540c\u6570\u636e\u7c7b\u578b\u7684\u5143\u7d20\u7684\u77e9\u5f62\u8868\u683c\u3002\u6bcf\u4e2a\u5143\u7d20\u7531\u5176\u884c\u548c\u5217\u7d22\u5f15\u552f\u4e00\u6807\u8bc6\u3002 \u8bfb\u53d6\u4e8c\u7ef4\u6570\u7ec4\u5143\u7d20 int[][] array = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}; \/\/ \u8bbf\u95ee\u7b2c\u4e00\u884c\u7b2c\u4e00\u5217\u7684\u5143\u7d20 int value1 = array[0][0]; \/\/ value1 = 1 \/\/ \u8bbf\u95ee\u6700\u540e\u4e00\u884c\u6700\u540e\u4e00\u5217\u7684\u5143\u7d20 int value2 = array[array.length &#8211; 1][array[0].length &#8211; 1]; \/\/ value2 = 9 \u767b\u5f55\u540e\u590d\u5236 \u5199\u5165\u4e8c\u7ef4\u6570\u7ec4\u5143\u7d20 \u7acb\u5373\u5b66\u4e60\u201c\u201d\uff1b int[][] array = [&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-39953","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/39953","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=39953"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/39953\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=39953"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=39953"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=39953"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}