{"id":66850,"date":"2025-05-03T16:21:02","date_gmt":"2025-05-03T08:21:02","guid":{"rendered":"https:\/\/fwq.ai\/blog\/66850\/"},"modified":"2025-05-03T16:21:02","modified_gmt":"2025-05-03T08:21:02","slug":"java%e6%80%8e%e4%b9%88%e5%88%9d%e5%a7%8b%e5%8c%96%e5%ad%97%e7%ac%a6%e4%b8%b2%e6%95%b0%e7%bb%84-2","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/66850\/","title":{"rendered":"java\u600e\u4e48\u521d\u59cb\u5316\u5b57\u7b26\u4e32\u6570\u7ec4"},"content":{"rendered":"<blockquote><p>\n  java \u4e2d\u521d\u59cb\u5316\u5b57\u7b26\u4e32\u6570\u7ec4\u7684\u65b9\u6cd5\u6709\u4e24\u79cd\uff1a\u76f4\u63a5\u8d4b\u503c\uff0c\u4f7f\u7528\u5927\u62ec\u53f7 {} \u76f4\u63a5\u5c06\u5b57\u7b26\u4e32\u8d4b\u503c\u7ed9\u6570\u7ec4\u5143\u7d20\uff1b\u4f7f\u7528 new \u5173\u952e\u5b57\u521b\u5efa\u6570\u7ec4\uff0c\u6307\u5b9a\u6570\u7ec4\u5927\u5c0f\u548c\u5143\u7d20\u7c7b\u578b\uff0c\u518d\u4f7f\u7528\u6570\u7ec4\u5143\u7d20\u7d22\u5f15\u8d4b\u503c\uff1b\u4e24\u79cd\u65b9\u6cd5\u90fd\u53ef\u4ee5\u4f7f\u7528\u6570\u7ec4\u521d\u59cb\u5316\u5757 {} \u7b80\u5316\u521d\u59cb\u5316\u8fc7\u7a0b\u3002\u5b57\u7b26\u4e32\u6570\u7ec4\u662f\u5f15\u7528\u7c7b\u578b\uff0c\u6570\u7ec4\u53d8\u91cf\u6307\u5411\u5b9e\u9645\u5b58\u50a8\u5b57\u7b26\u4e32\u503c\u7684\u6570\u7ec4\u5bf9\u8c61\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202411\/17\/2024111712245637880.jpg\" class=\"aligncenter\" title=\"java\u600e\u4e48\u521d\u59cb\u5316\u5b57\u7b26\u4e32\u6570\u7ec4\u63d2\u56fe\" alt=\"java\u600e\u4e48\u521d\u59cb\u5316\u5b57\u7b26\u4e32\u6570\u7ec4\u63d2\u56fe\" \/><\/p>\n<p><strong>Java \u4e2d\u521d\u59cb\u5316\u7684\u65b9\u6cd5<\/strong><\/p>\n<p>\u5728 Java \u4e2d\uff0c\u6709\u4e24\u79cd\u4e3b\u8981\u7684\u65b9\u6cd5\u6765\u521d\u59cb\u5316\u5b57\u7b26\u4e32\u6570\u7ec4\uff1a<\/p>\n<p><strong>\u65b9\u5f0f 1\uff1a\u76f4\u63a5\u8d4b\u503c<\/strong><\/p>\n<p>\u4f7f\u7528\u5927\u62ec\u53f7 {} \u76f4\u63a5\u5c06\u5b57\u7b26\u4e32\u8d4b\u503c\u7ed9\u6570\u7ec4\u5143\u7d20\uff1a<\/p>\n<p><span>\u7acb\u5373\u5b66\u4e60<\/span>\u201c\u201d\uff1b<\/p>\n<pre>String[] array1 = {\"Hello\", \"World\", \"Java\"};<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u65b9\u5f0f 2\uff1a\u4f7f\u7528 new \u5173\u952e\u5b57<\/strong><\/p>\n<p>\u4f7f\u7528 new \u5173\u952e\u5b57\u521b\u5efa\u6570\u7ec4\uff0c\u5e76\u6307\u5b9a\u6570\u7ec4\u5927\u5c0f\u548c\u5143\u7d20\u7c7b\u578b\u3002\u7136\u540e\uff0c\u4f7f\u7528\u6570\u7ec4\u5143\u7d20\u7684\u7d22\u5f15\u6765\u8d4b\u503c\uff1a<\/p>\n<pre>String[] array2 = new String[3];\narray2[0] = \"Hello\";\narray2[1] = \"World\";\narray2[2] = \"Java\";<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u5bf9\u4e8e\u8fd9\u4e24\u79cd\u65b9\u6cd5\uff0c\u90fd\u53ef\u4ee5\u4f7f\u7528\u6570\u7ec4\u521d\u59cb\u5316\u5757 {} \u6765\u7b80\u5316\u521d\u59cb\u5316\u8fc7\u7a0b\uff0c\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n<pre>\/\/ \u76f4\u63a5\u8d4b\u503c\uff0c\u4f7f\u7528\u6570\u7ec4\u521d\u59cb\u5316\u5757\nString[] array3 = new String[] {\"Hello\", \"World\", \"Java\"};\n\n\/\/ \u4f7f\u7528 new \u5173\u952e\u5b57\uff0c\u4f7f\u7528\u6570\u7ec4\u521d\u59cb\u5316\u5757\nString[] array4 = new String[] {null, null, null};\narray4[0] = \"Hello\";\narray4[1] = \"World\";\narray4[2] = \"Java\";<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u6ce8\u610f\uff1a<\/p>\n<ul>\n<li>\u4e24\u79cd\u65b9\u6cd5\u90fd\u53ef\u4ee5\u4f7f\u7528 for \u5faa\u73af\u6765\u904d\u5386\u6570\u7ec4\u5143\u7d20\u3002<\/li>\n<li>\u521d\u59cb\u5316\u6570\u7ec4\u540e\uff0c\u53ef\u4ee5\u4f7f\u7528 Arrays.toString(array) \u65b9\u6cd5\u6765\u6253\u5370\u6570\u7ec4\u4e2d\u7684\u6240\u6709\u5143\u7d20\u3002<\/li>\n<li>\u5b57\u7b26\u4e32\u6570\u7ec4\u662f\u5f15\u7528\u7c7b\u578b\uff0c\u56e0\u6b64\u6570\u7ec4\u53d8\u91cf\u6307\u5411\u5b9e\u9645\u5b58\u50a8\u5b57\u7b26\u4e32\u503c\u7684\u6570\u7ec4\u5bf9\u8c61\u3002<\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\u5c31\u662fjava\u600e\u4e48\u521d\u59cb\u5316\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\u521d\u59cb\u5316\u5b57\u7b26\u4e32\u6570\u7ec4\u7684\u65b9\u6cd5\u6709\u4e24\u79cd\uff1a\u76f4\u63a5\u8d4b\u503c\uff0c\u4f7f\u7528\u5927\u62ec\u53f7 {} \u76f4\u63a5\u5c06\u5b57\u7b26\u4e32\u8d4b\u503c\u7ed9\u6570\u7ec4\u5143\u7d20\uff1b\u4f7f\u7528 new \u5173\u952e\u5b57\u521b\u5efa\u6570\u7ec4\uff0c\u6307\u5b9a\u6570\u7ec4\u5927\u5c0f\u548c\u5143\u7d20\u7c7b\u578b\uff0c\u518d\u4f7f\u7528\u6570\u7ec4\u5143\u7d20\u7d22\u5f15\u8d4b\u503c\uff1b\u4e24\u79cd\u65b9\u6cd5\u90fd\u53ef\u4ee5\u4f7f\u7528\u6570\u7ec4\u521d\u59cb\u5316\u5757 {} \u7b80\u5316\u521d\u59cb\u5316\u8fc7\u7a0b\u3002\u5b57\u7b26\u4e32\u6570\u7ec4\u662f\u5f15\u7528\u7c7b\u578b\uff0c\u6570\u7ec4\u53d8\u91cf\u6307\u5411\u5b9e\u9645\u5b58\u50a8\u5b57\u7b26\u4e32\u503c\u7684\u6570\u7ec4\u5bf9\u8c61\u3002 Java \u4e2d\u521d\u59cb\u5316\u7684\u65b9\u6cd5 \u5728 Java \u4e2d\uff0c\u6709\u4e24\u79cd\u4e3b\u8981\u7684\u65b9\u6cd5\u6765\u521d\u59cb\u5316\u5b57\u7b26\u4e32\u6570\u7ec4\uff1a \u65b9\u5f0f 1\uff1a\u76f4\u63a5\u8d4b\u503c \u4f7f\u7528\u5927\u62ec\u53f7 {} \u76f4\u63a5\u5c06\u5b57\u7b26\u4e32\u8d4b\u503c\u7ed9\u6570\u7ec4\u5143\u7d20\uff1a \u7acb\u5373\u5b66\u4e60\u201c\u201d\uff1b String[] array1 = {&#8220;Hello&#8221;, &#8220;World&#8221;, &#8220;Java&#8221;}; \u767b\u5f55\u540e\u590d\u5236 \u65b9\u5f0f 2\uff1a\u4f7f\u7528 new \u5173\u952e\u5b57 \u4f7f\u7528 new \u5173\u952e\u5b57\u521b\u5efa\u6570\u7ec4\uff0c\u5e76\u6307\u5b9a\u6570\u7ec4\u5927\u5c0f\u548c\u5143\u7d20\u7c7b\u578b\u3002\u7136\u540e\uff0c\u4f7f\u7528\u6570\u7ec4\u5143\u7d20\u7684\u7d22\u5f15\u6765\u8d4b\u503c\uff1a String[] array2 = new String[3]; array2[0] = &#8220;Hello&#8221;; array2[1] = &#8220;World&#8221;; array2[2] = &#8220;Java&#8221;; \u767b\u5f55\u540e\u590d\u5236 \u5bf9\u4e8e\u8fd9\u4e24\u79cd\u65b9\u6cd5\uff0c\u90fd\u53ef\u4ee5\u4f7f\u7528\u6570\u7ec4\u521d\u59cb\u5316\u5757 {} \u6765\u7b80\u5316\u521d\u59cb\u5316\u8fc7\u7a0b\uff0c\u5982\u4e0b\u6240\u793a\uff1a \/\/ \u76f4\u63a5\u8d4b\u503c\uff0c\u4f7f\u7528\u6570\u7ec4\u521d\u59cb\u5316\u5757 String[] array3 [&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-66850","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/66850","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=66850"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/66850\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=66850"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=66850"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=66850"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}