{"id":66910,"date":"2025-05-03T09:27:34","date_gmt":"2025-05-03T01:27:34","guid":{"rendered":"https:\/\/fwq.ai\/blog\/66910\/"},"modified":"2025-05-03T09:27:34","modified_gmt":"2025-05-03T01:27:34","slug":"java%e4%b8%80%e4%b8%aa%e4%ba%8c%e7%bb%b4%e6%95%b0%e7%bb%84%e6%80%8e%e4%b9%88%e5%8f%96%e5%80%bc-2","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/66910\/","title":{"rendered":"java\u4e00\u4e2a\u4e8c\u7ef4\u6570\u7ec4\u600e\u4e48\u53d6\u503c"},"content":{"rendered":"<blockquote><p>\n  \u4e8c\u7ef4\u6570\u7ec4\u4e2d\u7684\u5143\u7d20\u53ef\u4ee5\u901a\u8fc7\u884c\u7d22\u5f15\u548c\u5217\u7d22\u5f15\u8bbf\u95ee\uff1a\u884c\u7d22\u5f15\u4ece 0 \u5f00\u59cb\uff0c\u8868\u793a\u884c\u53f7\u3002\u5217\u7d22\u5f15\u4ece 0 \u5f00\u59cb\uff0c\u8868\u793a\u5217\u53f7\u3002\u8bed\u6cd5\uff1aarrayrow\uff0c\u5176\u4e2d array \u662f\u6570\u7ec4\u540d\u79f0\uff0crow \u662f\u884c\u7d22\u5f15\uff0ccolumn \u662f\u5217\u7d22\u5f15\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202411\/17\/2024111718452320963.jpg\" class=\"aligncenter\" title=\"java\u4e00\u4e2a\u4e8c\u7ef4\u6570\u7ec4\u600e\u4e48\u53d6\u503c\u63d2\u56fe\" alt=\"java\u4e00\u4e2a\u4e8c\u7ef4\u6570\u7ec4\u600e\u4e48\u53d6\u503c\u63d2\u56fe\" \/><\/p>\n<p><strong>Java \u4e8c\u7ef4\u6570\u7ec4\u53d6\u503c<\/strong><\/p>\n<p>\u4e8c\u7ef4\u6570\u7ec4\u5728 Java \u4e2d\u662f\u4e00\u79cd\u6570\u636e\u7ed3\u6784\uff0c\u5b83\u53ef\u4ee5\u5b58\u50a8\u4e0d\u540c\u7c7b\u578b\u7684\u5143\u7d20\uff0c\u5e76\u6309\u884c\u548c\u5217\u8fdb\u884c\u7ec4\u7ec7\u3002\u8981\u8bbf\u95ee\u4e8c\u7ef4\u6570\u7ec4\u4e2d\u7684\u5143\u7d20\uff0c\u9700\u8981\u4f7f\u7528\u4e24\u4e2a\u7d22\u5f15\uff1a\u4e00\u4e2a\u8868\u793a\u884c\u53f7\uff0c\u53e6\u4e00\u4e2a\u8868\u793a\u5217\u53f7\u3002<\/p>\n<p><strong>\u8bed\u6cd5\uff1a<\/strong><\/p>\n<pre>array[row][column]<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u5176\u4e2d\uff1a<\/p>\n<p><span>\u7acb\u5373\u5b66\u4e60<\/span>\u201c\u201d\uff1b<\/p>\n<ul>\n<li> <strong>array<\/strong> \u662f\u4e8c\u7ef4\u6570\u7ec4\u7684\u540d\u79f0<\/li>\n<li> <strong>row<\/strong> \u662f\u5e0c\u671b\u8bbf\u95ee\u7684\u884c\u53f7\uff0c\u4ece 0 \u5f00\u59cb<\/li>\n<li> <strong>column<\/strong> \u662f\u5e0c\u671b\u8bbf\u95ee\u7684\u5217\u53f7\uff0c\u4e5f\u4ece 0 \u5f00\u59cb<\/li>\n<\/ul>\n<p><strong>\u793a\u4f8b\uff1a<\/strong><\/p>\n<p>\u5047\u8bbe\u6709\u4e00\u4e2a\u540d\u4e3a matrix \u7684\u4e8c\u7ef4\u6570\u7ec4\uff0c\u5305\u542b\u4ee5\u4e0b\u503c\uff1a<\/p>\n<pre>int[][] matrix = {\n    {1, 2},\n    {3, 4}\n};<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u8981\u8bbf\u95ee\u77e9\u9635\u4e2d\u7684\u5143\u7d20\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u8bed\u6cd5\uff1a<\/p>\n<pre>\/\/ \u8bbf\u95ee\u7b2c\u4e00\u884c\u7b2c\u4e00\u5217\u7684\u5143\u7d20\nint value1 = matrix[0][0];\n\n\/\/ \u8bbf\u95ee\u7b2c\u4e8c\u884c\u7b2c\u4e8c\u5217\u7684\u5143\u7d20\nint value2 = matrix[1][1];<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u53d8\u91cf value1 \u5c06\u5b58\u50a8\u503c 1\uff0c\u800c\u53d8\u91cf value2 \u5c06\u5b58\u50a8\u503c 4\u3002<\/p>\n<p><strong>\u6ce8\u610f\uff1a<\/strong><\/p>\n<p>\u5f53\u8bbf\u95ee\u6570\u7ec4\u5143\u7d20\u65f6\uff0c\u9700\u8981\u6ce8\u610f\u4ee5\u4e0b\u51e0\u70b9\uff1a<\/p>\n<ul>\n<li>\u884c\u7d22\u5f15\u548c\u5217\u7d22\u5f15\u90fd\u5fc5\u987b\u662f\u975e\u8d1f\u6574\u6570\u3002<\/li>\n<li>\u884c\u7d22\u5f15\u4e0d\u80fd\u8d85\u8fc7\u6570\u7ec4\u7684\u884c\u6570\u51cf 1\u3002<\/li>\n<li>\u5217\u7d22\u5f15\u4e0d\u80fd\u8d85\u8fc7\u6570\u7ec4\u7684\u5217\u6570\u51cf 1\u3002<\/li>\n<li>\u5982\u679c\u5c1d\u8bd5\u8bbf\u95ee\u8d85\u51fa\u8303\u56f4\u7684\u5143\u7d20\uff0c\u5c06\u629b\u51fa ArrayIndexOutOfBoundsException\u3002<\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\u5c31\u662fjava\u4e00\u4e2a\u4e8c\u7ef4\u6570\u7ec4\u600e\u4e48\u53d6\u503c\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>\u4e8c\u7ef4\u6570\u7ec4\u4e2d\u7684\u5143\u7d20\u53ef\u4ee5\u901a\u8fc7\u884c\u7d22\u5f15\u548c\u5217\u7d22\u5f15\u8bbf\u95ee\uff1a\u884c\u7d22\u5f15\u4ece 0 \u5f00\u59cb\uff0c\u8868\u793a\u884c\u53f7\u3002\u5217\u7d22\u5f15\u4ece 0 \u5f00\u59cb\uff0c\u8868\u793a\u5217\u53f7\u3002\u8bed\u6cd5\uff1aarrayrow\uff0c\u5176\u4e2d array \u662f\u6570\u7ec4\u540d\u79f0\uff0crow \u662f\u884c\u7d22\u5f15\uff0ccolumn \u662f\u5217\u7d22\u5f15\u3002 Java \u4e8c\u7ef4\u6570\u7ec4\u53d6\u503c \u4e8c\u7ef4\u6570\u7ec4\u5728 Java \u4e2d\u662f\u4e00\u79cd\u6570\u636e\u7ed3\u6784\uff0c\u5b83\u53ef\u4ee5\u5b58\u50a8\u4e0d\u540c\u7c7b\u578b\u7684\u5143\u7d20\uff0c\u5e76\u6309\u884c\u548c\u5217\u8fdb\u884c\u7ec4\u7ec7\u3002\u8981\u8bbf\u95ee\u4e8c\u7ef4\u6570\u7ec4\u4e2d\u7684\u5143\u7d20\uff0c\u9700\u8981\u4f7f\u7528\u4e24\u4e2a\u7d22\u5f15\uff1a\u4e00\u4e2a\u8868\u793a\u884c\u53f7\uff0c\u53e6\u4e00\u4e2a\u8868\u793a\u5217\u53f7\u3002 \u8bed\u6cd5\uff1a array[row][column] \u767b\u5f55\u540e\u590d\u5236 \u5176\u4e2d\uff1a \u7acb\u5373\u5b66\u4e60\u201c\u201d\uff1b array \u662f\u4e8c\u7ef4\u6570\u7ec4\u7684\u540d\u79f0 row \u662f\u5e0c\u671b\u8bbf\u95ee\u7684\u884c\u53f7\uff0c\u4ece 0 \u5f00\u59cb column \u662f\u5e0c\u671b\u8bbf\u95ee\u7684\u5217\u53f7\uff0c\u4e5f\u4ece 0 \u5f00\u59cb \u793a\u4f8b\uff1a \u5047\u8bbe\u6709\u4e00\u4e2a\u540d\u4e3a matrix \u7684\u4e8c\u7ef4\u6570\u7ec4\uff0c\u5305\u542b\u4ee5\u4e0b\u503c\uff1a int[][] matrix = { {1, 2}, {3, 4} }; \u767b\u5f55\u540e\u590d\u5236 \u8981\u8bbf\u95ee\u77e9\u9635\u4e2d\u7684\u5143\u7d20\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u8bed\u6cd5\uff1a \/\/ \u8bbf\u95ee\u7b2c\u4e00\u884c\u7b2c\u4e00\u5217\u7684\u5143\u7d20 int value1 = matrix[0][0]; \/\/ \u8bbf\u95ee\u7b2c\u4e8c\u884c\u7b2c\u4e8c\u5217\u7684\u5143\u7d20 int value2 = [&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-66910","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/66910","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=66910"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/66910\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=66910"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=66910"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=66910"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}