{"id":66637,"date":"2025-05-03T13:07:26","date_gmt":"2025-05-03T05:07:26","guid":{"rendered":"https:\/\/fwq.ai\/blog\/66637\/"},"modified":"2025-05-03T13:07:26","modified_gmt":"2025-05-03T05:07:26","slug":"java%e6%80%8e%e4%b9%88%e5%be%97%e5%88%b0%e7%a9%ba%e7%9a%84%e6%95%b0%e7%bb%84%e7%9a%84%e9%95%bf%e5%ba%a6-2","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/66637\/","title":{"rendered":"java\u600e\u4e48\u5f97\u5230\u7a7a\u7684\u6570\u7ec4\u7684\u957f\u5ea6"},"content":{"rendered":"<blockquote><p>\n  java\u4e2d\u83b7\u53d6\u7a7a\u6570\u7ec4\u7684\u957f\u5ea6\u4e3a0\u3002\u5373\u4f7f\u662f\u591a\u7ef4\u6570\u7ec4\uff0c\u53ea\u8981\u4efb\u4f55\u7ef4\u5ea6\u4e3a\u7a7a\uff0c\u6574\u4e2a\u6570\u7ec4\u7684\u957f\u5ea6\u4e5f\u4e3a0\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202411\/16\/2024111611244976458.jpg\" class=\"aligncenter\" title=\"java\u600e\u4e48\u5f97\u5230\u7a7a\u7684\u6570\u7ec4\u7684\u957f\u5ea6\u63d2\u56fe\" alt=\"java\u600e\u4e48\u5f97\u5230\u7a7a\u7684\u6570\u7ec4\u7684\u957f\u5ea6\u63d2\u56fe\" \/><\/p>\n<p><strong>Java\u4e2d\u83b7\u53d6\u7a7a\u6570\u7ec4\u7684\u957f\u5ea6<\/strong><\/p>\n<p>\u5728Java\u4e2d\uff0c\u83b7\u53d6\u6570\u7ec4\u7684\u957f\u5ea6\u975e\u5e38\u7b80\u5355\uff0c\u76f4\u63a5\u4f7f\u7528length\u5c5e\u6027\u5373\u53ef\u3002\u4f46\u662f\uff0c\u5bf9\u4e8e\u7a7a\u6570\u7ec4\uff0clength\u5c5e\u6027\u8fd4\u56de\u7684\u503c\u53ef\u80fd\u4ee4\u4eba\u56f0\u60d1\u3002<\/p>\n<p><strong>\u7a7a\u6570\u7ec4\u7684\u957f\u5ea6<\/strong><\/p>\n<p>\u6839\u636eJava\u7684\u5b9a\u4e49\uff0c\u7a7a\u6570\u7ec4\u7684\u957f\u5ea6\u4e3a<strong>0<\/strong>\u3002\u5373\u4f7f\u8be5\u6570\u7ec4\u662f\u591a\u7ef4\u6570\u7ec4\uff0c\u53ea\u8981\u4efb\u4f55\u7ef4\u5ea6\u4e3a\u7a7a\uff0c\u6574\u4e2a\u6570\u7ec4\u7684\u957f\u5ea6\u90fd\u5c06\u4e3a0\u3002<\/p>\n<p><span>\u7acb\u5373\u5b66\u4e60<\/span>\u201c\u201d\uff1b<\/p>\n<p><strong>\u793a\u4f8b\u4ee3\u7801<\/strong><\/p>\n<pre>int[] emptyArray = new int[0];\nSystem.out.println(emptyArray.length); \/\/ \u8f93\u51fa\uff1a0\n\nint[][] empty2DArray = new int[3][0];\nSystem.out.println(empty2DArray.length); \/\/ \u8f93\u51fa\uff1a3\nSystem.out.println(empty2DArray[0].length); \/\/ \u8f93\u51fa\uff1a0<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u89e3\u91ca<\/strong><\/p>\n<p>\u7b2c\u4e00\u4e2a\u793a\u4f8b\u521b\u5efa\u4e86\u4e00\u4e2a\u5305\u542b0\u4e2a\u5143\u7d20\u7684\u4e00\u7ef4\u7a7a\u6570\u7ec4\uff0c\u56e0\u6b64\u5176\u957f\u5ea6\u4e3a0\u3002\u7b2c\u4e8c\u4e2a\u793a\u4f8b\u521b\u5efa\u4e86\u4e00\u4e2a3\u884c0\u5217\u7684\u4e8c\u7ef4\u7a7a\u6570\u7ec4\uff0c\u5373\u6bcf\u884c\u90fd\u662f\u7a7a\u7684\u3002\u867d\u7136\u8be5\u6570\u7ec4\u67093\u884c\uff0c\u4f46\u6bcf\u884c\u90fd\u6ca1\u6709\u5143\u7d20\uff0c\u56e0\u6b64\u5176\u6574\u4f53\u957f\u5ea6\u4ecd\u4e3a0\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fjava\u600e\u4e48\u5f97\u5230\u7a7a\u7684\u6570\u7ec4\u7684\u957f\u5ea6\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\u83b7\u53d6\u7a7a\u6570\u7ec4\u7684\u957f\u5ea6\u4e3a0\u3002\u5373\u4f7f\u662f\u591a\u7ef4\u6570\u7ec4\uff0c\u53ea\u8981\u4efb\u4f55\u7ef4\u5ea6\u4e3a\u7a7a\uff0c\u6574\u4e2a\u6570\u7ec4\u7684\u957f\u5ea6\u4e5f\u4e3a0\u3002 Java\u4e2d\u83b7\u53d6\u7a7a\u6570\u7ec4\u7684\u957f\u5ea6 \u5728Java\u4e2d\uff0c\u83b7\u53d6\u6570\u7ec4\u7684\u957f\u5ea6\u975e\u5e38\u7b80\u5355\uff0c\u76f4\u63a5\u4f7f\u7528length\u5c5e\u6027\u5373\u53ef\u3002\u4f46\u662f\uff0c\u5bf9\u4e8e\u7a7a\u6570\u7ec4\uff0clength\u5c5e\u6027\u8fd4\u56de\u7684\u503c\u53ef\u80fd\u4ee4\u4eba\u56f0\u60d1\u3002 \u7a7a\u6570\u7ec4\u7684\u957f\u5ea6 \u6839\u636eJava\u7684\u5b9a\u4e49\uff0c\u7a7a\u6570\u7ec4\u7684\u957f\u5ea6\u4e3a0\u3002\u5373\u4f7f\u8be5\u6570\u7ec4\u662f\u591a\u7ef4\u6570\u7ec4\uff0c\u53ea\u8981\u4efb\u4f55\u7ef4\u5ea6\u4e3a\u7a7a\uff0c\u6574\u4e2a\u6570\u7ec4\u7684\u957f\u5ea6\u90fd\u5c06\u4e3a0\u3002 \u7acb\u5373\u5b66\u4e60\u201c\u201d\uff1b \u793a\u4f8b\u4ee3\u7801 int[] emptyArray = new int[0]; System.out.println(emptyArray.length); \/\/ \u8f93\u51fa\uff1a0 int[][] empty2DArray = new int[3][0]; System.out.println(empty2DArray.length); \/\/ \u8f93\u51fa\uff1a3 System.out.println(empty2DArray[0].length); \/\/ \u8f93\u51fa\uff1a0 \u767b\u5f55\u540e\u590d\u5236 \u89e3\u91ca \u7b2c\u4e00\u4e2a\u793a\u4f8b\u521b\u5efa\u4e86\u4e00\u4e2a\u5305\u542b0\u4e2a\u5143\u7d20\u7684\u4e00\u7ef4\u7a7a\u6570\u7ec4\uff0c\u56e0\u6b64\u5176\u957f\u5ea6\u4e3a0\u3002\u7b2c\u4e8c\u4e2a\u793a\u4f8b\u521b\u5efa\u4e86\u4e00\u4e2a3\u884c0\u5217\u7684\u4e8c\u7ef4\u7a7a\u6570\u7ec4\uff0c\u5373\u6bcf\u884c\u90fd\u662f\u7a7a\u7684\u3002\u867d\u7136\u8be5\u6570\u7ec4\u67093\u884c\uff0c\u4f46\u6bcf\u884c\u90fd\u6ca1\u6709\u5143\u7d20\uff0c\u56e0\u6b64\u5176\u6574\u4f53\u957f\u5ea6\u4ecd\u4e3a0\u3002 \u4ee5\u4e0a\u5c31\u662fjava\u600e\u4e48\u5f97\u5230\u7a7a\u7684\u6570\u7ec4\u7684\u957f\u5ea6\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-66637","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/66637","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=66637"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/66637\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=66637"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=66637"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=66637"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}