{"id":67004,"date":"2025-05-03T08:23:26","date_gmt":"2025-05-03T00:23:26","guid":{"rendered":"https:\/\/fwq.ai\/blog\/67004\/"},"modified":"2025-05-03T08:23:26","modified_gmt":"2025-05-03T00:23:26","slug":"java%e6%80%8e%e4%b9%88%e5%ae%9a%e4%b9%89%e5%ad%97%e7%ac%a6%e4%b8%b2%e4%ba%8c%e7%bb%b4%e6%95%b0%e7%bb%84-2","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/67004\/","title":{"rendered":"Java\u600e\u4e48\u5b9a\u4e49\u5b57\u7b26\u4e32\u4e8c\u7ef4\u6570\u7ec4"},"content":{"rendered":"<blockquote><p>\n  \u6458\u8981\uff1a\u5b57\u7b26\u4e32\u4e8c\u7ef4\u6570\u7ec4\u901a\u8fc7\u4f7f\u7528\u4ee5\u4e0b\u8bed\u6cd5\u6765\u5b9a\u4e49\uff1astring[][] arrayname = new stringnumrows;\u3002\u5b83\u5305\u542b\u591a\u4e2a\u88ab\u7ec4\u7ec7\u6210\u884c\u548c\u5217\u7684\u5b57\u7b26\u4e32\u3002\u53ef\u4ee5\u901a\u8fc7\u5d4c\u5957\u5faa\u73af\u8bbf\u95ee\u548c\u64cd\u4f5c\u5143\u7d20\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202411\/17\/2024111722541614393.jpg\" class=\"aligncenter\" title=\"Java\u600e\u4e48\u5b9a\u4e49\u5b57\u7b26\u4e32\u4e8c\u7ef4\u6570\u7ec4\u63d2\u56fe\" alt=\"Java\u600e\u4e48\u5b9a\u4e49\u5b57\u7b26\u4e32\u4e8c\u7ef4\u6570\u7ec4\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5982\u4f55\u5728 Java \u4e2d\u5b9a\u4e49\u5b57\u7b26\u4e32\u4e8c\u7ef4\u6570\u7ec4<\/strong><\/p>\n<p>\u5b57\u7b26\u4e32\u4e8c\u7ef4\u6570\u7ec4\u662f\u4e00\u79cd\u6570\u636e\u7ed3\u6784\uff0c\u5b83\u53ef\u4ee5\u5b58\u50a8\u591a\u4e2a\u5b57\u7b26\u4e32\uff0c\u8fd9\u4e9b\u5b57\u7b26\u4e32\u88ab\u7ec4\u7ec7\u6210\u884c\u548c\u5217\u3002\u8981\u5b9a\u4e49\u4e00\u4e2a\u5b57\u7b26\u4e32\u4e8c\u7ef4\u6570\u7ec4\uff0c\u9700\u8981\u4f7f\u7528\u4ee5\u4e0b\u8bed\u6cd5\uff1a<\/p>\n<pre>String[][] arrayName = new String[numRows][numCols];<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u5176\u4e2d\uff1a<\/p>\n<ul>\n<li>arrayName \u662f\u4e8c\u7ef4\u6570\u7ec4\u7684\u540d\u79f0\u3002<\/li>\n<li>numRows \u662f\u4e8c\u7ef4\u6570\u7ec4\u7684\u884c\u6570\u3002<\/li>\n<li>numCols \u662f\u4e8c\u7ef4\u6570\u7ec4\u7684\u5217\u6570\u3002<\/li>\n<\/ul>\n<p>\u4f8b\u5982\uff0c\u8981\u5b9a\u4e49\u4e00\u4e2a\u5177\u6709 3 \u884c\u548c 4 \u5217\u7684\u5b57\u7b26\u4e32\u4e8c\u7ef4\u6570\u7ec4\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u4ee3\u7801\uff1a<\/p>\n<p><span>\u7acb\u5373\u5b66\u4e60<\/span>\u201c\u201d\uff1b<\/p>\n<pre>String[][] myArray = new String[3][4];<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u73b0\u5728\uff0c\u4f60\u5c31\u53ef\u4ee5\u4f7f\u7528\u5d4c\u5957\u5faa\u73af\u6765\u8bbf\u95ee\u548c\u64cd\u4f5c\u4e8c\u7ef4\u6570\u7ec4\u4e2d\u7684\u5143\u7d20\u3002\u4ee5\u4e0b\u793a\u4f8b\u663e\u793a\u4e86\u5982\u4f55\u8bbe\u7f6e\u548c\u83b7\u53d6\u4e8c\u7ef4\u6570\u7ec4\u4e2d\u7684\u503c\uff1a<\/p>\n<pre>myArray[0][0] = \"Hello\";  \/\/ \u8bbe\u7f6e\u7b2c\u4e00\u884c\u7b2c\u4e00\u5217\u7684\u503c\nSystem.out.println(myArray[1][2]);  \/\/ \u83b7\u53d6\u7b2c\u4e8c\u884c\u7b2c\u4e09\u5217\u7684\u503c<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u4e8c\u7ef4\u6570\u7ec4\u7684\u884c\u548c\u5217\u7d22\u5f15\u662f\u4ece 0 \u5f00\u59cb\u7684\u3002\u8fd9\u610f\u5473\u7740\u4e8c\u7ef4\u6570\u7ec4 myArray \u7684\u7b2c\u4e00\u4e2a\u5143\u7d20\u4f4d\u4e8e myArray[0][0]\uff0c\u800c\u4e0d\u662f myArray[1][1]\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fJava\u600e\u4e48\u5b9a\u4e49\u5b57\u7b26\u4e32\u4e8c\u7ef4\u6570\u7ec4\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>\u6458\u8981\uff1a\u5b57\u7b26\u4e32\u4e8c\u7ef4\u6570\u7ec4\u901a\u8fc7\u4f7f\u7528\u4ee5\u4e0b\u8bed\u6cd5\u6765\u5b9a\u4e49\uff1astring[][] arrayname = new stringnumrows;\u3002\u5b83\u5305\u542b\u591a\u4e2a\u88ab\u7ec4\u7ec7\u6210\u884c\u548c\u5217\u7684\u5b57\u7b26\u4e32\u3002\u53ef\u4ee5\u901a\u8fc7\u5d4c\u5957\u5faa\u73af\u8bbf\u95ee\u548c\u64cd\u4f5c\u5143\u7d20\u3002 \u5982\u4f55\u5728 Java \u4e2d\u5b9a\u4e49\u5b57\u7b26\u4e32\u4e8c\u7ef4\u6570\u7ec4 \u5b57\u7b26\u4e32\u4e8c\u7ef4\u6570\u7ec4\u662f\u4e00\u79cd\u6570\u636e\u7ed3\u6784\uff0c\u5b83\u53ef\u4ee5\u5b58\u50a8\u591a\u4e2a\u5b57\u7b26\u4e32\uff0c\u8fd9\u4e9b\u5b57\u7b26\u4e32\u88ab\u7ec4\u7ec7\u6210\u884c\u548c\u5217\u3002\u8981\u5b9a\u4e49\u4e00\u4e2a\u5b57\u7b26\u4e32\u4e8c\u7ef4\u6570\u7ec4\uff0c\u9700\u8981\u4f7f\u7528\u4ee5\u4e0b\u8bed\u6cd5\uff1a String[][] arrayName = new String[numRows][numCols]; \u767b\u5f55\u540e\u590d\u5236 \u5176\u4e2d\uff1a arrayName \u662f\u4e8c\u7ef4\u6570\u7ec4\u7684\u540d\u79f0\u3002 numRows \u662f\u4e8c\u7ef4\u6570\u7ec4\u7684\u884c\u6570\u3002 numCols \u662f\u4e8c\u7ef4\u6570\u7ec4\u7684\u5217\u6570\u3002 \u4f8b\u5982\uff0c\u8981\u5b9a\u4e49\u4e00\u4e2a\u5177\u6709 3 \u884c\u548c 4 \u5217\u7684\u5b57\u7b26\u4e32\u4e8c\u7ef4\u6570\u7ec4\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u4ee3\u7801\uff1a \u7acb\u5373\u5b66\u4e60\u201c\u201d\uff1b String[][] myArray = new String[3][4]; \u767b\u5f55\u540e\u590d\u5236 \u73b0\u5728\uff0c\u4f60\u5c31\u53ef\u4ee5\u4f7f\u7528\u5d4c\u5957\u5faa\u73af\u6765\u8bbf\u95ee\u548c\u64cd\u4f5c\u4e8c\u7ef4\u6570\u7ec4\u4e2d\u7684\u5143\u7d20\u3002\u4ee5\u4e0b\u793a\u4f8b\u663e\u793a\u4e86\u5982\u4f55\u8bbe\u7f6e\u548c\u83b7\u53d6\u4e8c\u7ef4\u6570\u7ec4\u4e2d\u7684\u503c\uff1a myArray[0][0] = &#8220;Hello&#8221;; \/\/ \u8bbe\u7f6e\u7b2c\u4e00\u884c\u7b2c\u4e00\u5217\u7684\u503c System.out.println(myArray[1][2]); \/\/ \u83b7\u53d6\u7b2c\u4e8c\u884c\u7b2c\u4e09\u5217\u7684\u503c \u767b\u5f55\u540e\u590d\u5236 \u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u4e8c\u7ef4\u6570\u7ec4\u7684\u884c\u548c\u5217\u7d22\u5f15\u662f\u4ece 0 \u5f00\u59cb\u7684\u3002\u8fd9\u610f\u5473\u7740\u4e8c\u7ef4\u6570\u7ec4 myArray \u7684\u7b2c\u4e00\u4e2a\u5143\u7d20\u4f4d\u4e8e myArray[0][0]\uff0c\u800c\u4e0d\u662f myArray[1][1]\u3002 \u4ee5\u4e0a\u5c31\u662fJava\u600e\u4e48\u5b9a\u4e49\u5b57\u7b26\u4e32\u4e8c\u7ef4\u6570\u7ec4\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8IDCBABY\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/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-67004","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/67004","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=67004"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/67004\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=67004"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=67004"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=67004"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}