{"id":66879,"date":"2025-05-03T13:50:12","date_gmt":"2025-05-03T05:50:12","guid":{"rendered":"https:\/\/fwq.ai\/blog\/66879\/"},"modified":"2025-05-03T13:50:12","modified_gmt":"2025-05-03T05:50:12","slug":"java%e6%80%8e%e4%b9%88%e6%8e%a5%e5%8f%97%e4%b8%80%e4%b8%aa%e4%ba%8c%e7%bb%b4%e6%95%b0%e7%bb%84-2","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/66879\/","title":{"rendered":"Java\u600e\u4e48\u63a5\u53d7\u4e00\u4e2a\u4e8c\u7ef4\u6570\u7ec4"},"content":{"rendered":"<blockquote><p>\n  java \u4e2d\u63a5\u6536\u4e8c\u7ef4\u6570\u7ec4\u6709\u4e24\u79cd\u65b9\u6cd5\u3002\u65b9\u6cd5 1\uff1a\u4f7f\u7528\u591a\u7ef4\u6570\u7ec4\u8bed\u6cd5\uff08int[][] arrayname = new intnum_rows\uff09\u3002\u65b9\u6cd5 2\uff1a\u4f7f\u7528\u6570\u7ec4\u7684\u6570\u7ec4\uff08int[] arrayname[]\uff1b\u4e3a\u6bcf\u4e2a\u4e00\u7ef4\u6570\u7ec4\u5206\u914d\u5185\u5b58\uff09\u3002\u63a5\u6536\u4e8c\u7ef4\u6570\u7ec4\uff1a\u76f4\u63a5\u8d4b\u503c\u3001\u901a\u8fc7\u51fd\u6570\u4f20\u9012\u3001\u901a\u8fc7\u65b9\u6cd5\u8fd4\u56de\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202411\/17\/2024111714071031730.jpg\" class=\"aligncenter\" title=\"Java\u600e\u4e48\u63a5\u53d7\u4e00\u4e2a\u4e8c\u7ef4\u6570\u7ec4\u63d2\u56fe\" alt=\"Java\u600e\u4e48\u63a5\u53d7\u4e00\u4e2a\u4e8c\u7ef4\u6570\u7ec4\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5982\u4f55\u5728 Java \u4e2d\u63a5\u53d7\u4e00\u4e2a\u4e8c\u7ef4\u6570\u7ec4<\/strong><\/p>\n<p>Java \u4e2d\u63a5\u53d7\u4e8c\u7ef4\u6570\u7ec4\u6709\u4e24\u79cd\u4e3b\u8981\u65b9\u6cd5\uff1a<\/p>\n<p><strong>\u65b9\u6cd5 1\uff1a\u4f7f\u7528\u591a\u7ef4\u6570\u7ec4\u8bed\u6cd5<\/strong><\/p>\n<ul>\n<li>\u58f0\u660e\u4e00\u4e2a\u591a\u7ef4\u6570\u7ec4\u7c7b\u578b\uff1aint[][] arrayName;<\/li>\n<li>\u4f7f\u7528 new \u5173\u952e\u5b57\u5206\u914d\u5185\u5b58\uff1aarrayName = new int[num_rows][num_cols];<\/li>\n<\/ul>\n<pre>\/\/ \u58f0\u660e\u4e00\u4e2a 3x4 \u4e8c\u7ef4\u6570\u7ec4\nint[][] myArray = new int[3][4];<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u65b9\u6cd5 2\uff1a\u4f7f\u7528\u6570\u7ec4\u7684\u6570\u7ec4<\/strong><\/p>\n<p><span>\u7acb\u5373\u5b66\u4e60<\/span>\u201c\u201d\uff1b<\/p>\n<ul>\n<li>\u58f0\u660e\u4e00\u4e2a\u4e00\u7ef4\u6570\u7ec4\uff0c\u5176\u5143\u7d20\u662f\u5176\u4ed6\u4e00\u7ef4\u6570\u7ec4\uff1aint[] arrayName[];<\/li>\n<li>\u4f7f\u7528 new \u5173\u952e\u5b57\u5206\u522b\u4e3a\u6bcf\u4e2a\u4e00\u7ef4\u6570\u7ec4\u5206\u914d\u5185\u5b58\uff1a<\/li>\n<\/ul>\n<pre>\/\/ \u58f0\u660e\u4e00\u4e2a\u5305\u542b 3 \u4e2a\u4e00\u7ef4\u6570\u7ec4\u7684\u6570\u7ec4\nint[][] myArray = new int[3][];\n\n\/\/ \u5206\u522b\u4e3a\u6bcf\u4e2a\u4e00\u7ef4\u6570\u7ec4\u5206\u914d\u5185\u5b58\nmyArray[0] = new int[2];\nmyArray[1] = new int[3];\nmyArray[2] = new int[4];<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u63a5\u6536\u4e8c\u7ef4\u6570\u7ec4<\/strong><\/p>\n<p>\u4e00\u65e6\u58f0\u660e\u5e76\u5206\u914d\u4e86\u4e8c\u7ef4\u6570\u7ec4\uff0c\u5c31\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u65b9\u5f0f\u63a5\u6536\u5b83\uff1a<\/p>\n<ul>\n<li> <strong>\u76f4\u63a5\u8d4b\u503c\uff1a<\/strong>\u76f4\u63a5\u5c06\u4e8c\u7ef4\u6570\u7ec4\u8d4b\u503c\u7ed9\u5df2\u58f0\u660e\u7684\u53d8\u91cf\u3002<\/li>\n<li> <strong>\u901a\u8fc7\u51fd\u6570\u4f20\u9012\uff1a<\/strong>\u5c06\u4e8c\u7ef4\u6570\u7ec4\u4f5c\u4e3a\u53c2\u6570\u4f20\u9012\u7ed9\u51fd\u6570\u3002<\/li>\n<li> <strong>\u901a\u8fc7\u65b9\u6cd5\u8fd4\u56de\uff1a<\/strong>\u4ece\u65b9\u6cd5\u4e2d\u8fd4\u56de\u4e00\u4e2a\u4e8c\u7ef4\u6570\u7ec4\u3002<\/li>\n<\/ul>\n<p><strong>\u793a\u4f8b<\/strong><\/p>\n<pre>\/\/ \u76f4\u63a5\u8d4b\u503c\nint[][] myArray = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};\n\n\/\/ \u901a\u8fc7\u51fd\u6570\u4f20\u9012\nvoid myFunction(int[][] array) {\n    \/\/ \u8bbf\u95ee\u6570\u7ec4\u5143\u7d20\n}\n\n\/\/ \u901a\u8fc7\u65b9\u6cd5\u8fd4\u56de\nint[][] createArray() {\n    return new int[][]{{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fJava\u600e\u4e48\u63a5\u53d7\u4e00\u4e2a\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>java \u4e2d\u63a5\u6536\u4e8c\u7ef4\u6570\u7ec4\u6709\u4e24\u79cd\u65b9\u6cd5\u3002\u65b9\u6cd5 1\uff1a\u4f7f\u7528\u591a\u7ef4\u6570\u7ec4\u8bed\u6cd5\uff08int[][] arrayname = new intnum_rows\uff09\u3002\u65b9\u6cd5 2\uff1a\u4f7f\u7528\u6570\u7ec4\u7684\u6570\u7ec4\uff08int[] arrayname[]\uff1b\u4e3a\u6bcf\u4e2a\u4e00\u7ef4\u6570\u7ec4\u5206\u914d\u5185\u5b58\uff09\u3002\u63a5\u6536\u4e8c\u7ef4\u6570\u7ec4\uff1a\u76f4\u63a5\u8d4b\u503c\u3001\u901a\u8fc7\u51fd\u6570\u4f20\u9012\u3001\u901a\u8fc7\u65b9\u6cd5\u8fd4\u56de\u3002 \u5982\u4f55\u5728 Java \u4e2d\u63a5\u53d7\u4e00\u4e2a\u4e8c\u7ef4\u6570\u7ec4 Java \u4e2d\u63a5\u53d7\u4e8c\u7ef4\u6570\u7ec4\u6709\u4e24\u79cd\u4e3b\u8981\u65b9\u6cd5\uff1a \u65b9\u6cd5 1\uff1a\u4f7f\u7528\u591a\u7ef4\u6570\u7ec4\u8bed\u6cd5 \u58f0\u660e\u4e00\u4e2a\u591a\u7ef4\u6570\u7ec4\u7c7b\u578b\uff1aint[][] arrayName; \u4f7f\u7528 new \u5173\u952e\u5b57\u5206\u914d\u5185\u5b58\uff1aarrayName = new int[num_rows][num_cols]; \/\/ \u58f0\u660e\u4e00\u4e2a 3&#215;4 \u4e8c\u7ef4\u6570\u7ec4 int[][] myArray = new int[3][4]; \u767b\u5f55\u540e\u590d\u5236 \u65b9\u6cd5 2\uff1a\u4f7f\u7528\u6570\u7ec4\u7684\u6570\u7ec4 \u7acb\u5373\u5b66\u4e60\u201c\u201d\uff1b \u58f0\u660e\u4e00\u4e2a\u4e00\u7ef4\u6570\u7ec4\uff0c\u5176\u5143\u7d20\u662f\u5176\u4ed6\u4e00\u7ef4\u6570\u7ec4\uff1aint[] arrayName[]; \u4f7f\u7528 new \u5173\u952e\u5b57\u5206\u522b\u4e3a\u6bcf\u4e2a\u4e00\u7ef4\u6570\u7ec4\u5206\u914d\u5185\u5b58\uff1a \/\/ \u58f0\u660e\u4e00\u4e2a\u5305\u542b 3 \u4e2a\u4e00\u7ef4\u6570\u7ec4\u7684\u6570\u7ec4 int[][] myArray = new int[3][]; \/\/ \u5206\u522b\u4e3a\u6bcf\u4e2a\u4e00\u7ef4\u6570\u7ec4\u5206\u914d\u5185\u5b58 myArray[0] = [&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-66879","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/66879","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=66879"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/66879\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=66879"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=66879"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=66879"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}