{"id":65926,"date":"2025-05-03T11:10:40","date_gmt":"2025-05-03T03:10:40","guid":{"rendered":"https:\/\/fwq.ai\/blog\/65926\/"},"modified":"2025-05-03T11:10:40","modified_gmt":"2025-05-03T03:10:40","slug":"java%e7%94%a8new%e6%80%8e%e4%b9%88%e5%88%9b%e5%bb%ba%e5%af%b9%e8%b1%a1%e6%95%b0%e7%bb%84-2","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/65926\/","title":{"rendered":"java\u7528new\u600e\u4e48\u521b\u5efa\u5bf9\u8c61\u6570\u7ec4"},"content":{"rendered":"<blockquote><p>\n  java \u4e2d\u4f7f\u7528 new \u521b\u5efa\u5bf9\u8c61\u6570\u7ec4\u7684\u8bed\u6cd5\u4e3a\uff1aobjectname[] arrayname = new objectname[size]\uff0c\u5176\u4e2d objectname \u662f\u8981\u521b\u5efa\u7684\u6570\u7ec4\u5143\u7d20\u7684\u7c7b\u540d\uff0carrayname \u662f\u6570\u7ec4\u7684\u540d\u79f0\uff0csize \u662f\u6570\u7ec4\u7684\u5927\u5c0f\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202411\/13\/2024111316152046001.jpg\" class=\"aligncenter\" title=\"java\u7528new\u600e\u4e48\u521b\u5efa\u5bf9\u8c61\u6570\u7ec4\u63d2\u56fe\" alt=\"java\u7528new\u600e\u4e48\u521b\u5efa\u5bf9\u8c61\u6570\u7ec4\u63d2\u56fe\" \/><\/p>\n<p><strong>Java \u4f7f\u7528 new \u521b\u5efa\u5bf9\u8c61\u6570\u7ec4<\/strong><\/p>\n<p><strong>\u95ee\uff1aJava \u4e2d\u5982\u4f55\u4f7f\u7528 new \u521b\u5efa\u5bf9\u8c61\u6570\u7ec4\uff1f<\/strong><\/p>\n<p><strong>\u7b54\uff1a<\/strong>Java \u4e2d\u4f7f\u7528 new \u521b\u5efa\u5bf9\u8c61\u6570\u7ec4\u7684\u8bed\u6cd5\u5982\u4e0b\uff1a<\/p>\n<pre>ObjectName[] arrayName = new ObjectName[size];<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u5176\u4e2d\uff0c<strong>ObjectName<\/strong> \u662f\u8981\u521b\u5efa\u7684\u6570\u7ec4\u5143\u7d20\u7684\u7c7b\u540d\uff0c<strong>arrayName<\/strong> \u662f\u6570\u7ec4\u7684\u540d\u79f0\uff0c<strong>size<\/strong> \u662f\u6570\u7ec4\u7684\u5927\u5c0f\u3002<\/p>\n<p><span>\u7acb\u5373\u5b66\u4e60<\/span>\u201c\u201d\uff1b<\/p>\n<p><strong>\u5c55\u5f00\u89e3\u7b54\uff1a<\/strong><\/p>\n<ul>\n<li> <strong>\u7c7b\u540d\uff1a<\/strong>\u6307\u5b9a\u8981\u521b\u5efa\u7684\u6570\u7ec4\u5143\u7d20\u7684\u7c7b\u3002\u4f8b\u5982\uff0c\u8981\u521b\u5efa String \u6570\u7ec4\uff0c\u7c7b\u540d\u5c31\u662f String\u3002<\/li>\n<li> <strong>\u6570\u7ec4\u540d\u79f0\uff1a<\/strong>\u4e3a\u6570\u7ec4\u6307\u5b9a\u4e00\u4e2a\u6807\u8bc6\u7b26\u3002<\/li>\n<li> <strong>\u6570\u7ec4\u5927\u5c0f\uff1a<\/strong>\u6307\u5b9a\u6570\u7ec4\u8981\u5305\u542b\u7684\u5143\u7d20\u6570\u91cf\u3002<\/li>\n<\/ul>\n<p><strong>\u4f8b\u5982\uff1a<\/strong><\/p>\n<pre>String[] names = new String[5];<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u8fd9\u5c06\u521b\u5efa\u4e00\u4e2a\u5305\u542b 5 \u4e2a String \u5143\u7d20\u7684\u6570\u7ec4\uff0c\u540d\u4e3a names\u3002<\/p>\n<p><strong>\u6ce8\u610f\u4e8b\u9879\uff1a<\/strong><\/p>\n<ul>\n<li>\u6570\u7ec4\u5927\u5c0f\u5fc5\u987b\u662f\u4e00\u4e2a\u6b63\u6574\u6570\u3002<\/li>\n<li>\u521b\u5efa\u6570\u7ec4\u540e\uff0c\u5176\u5927\u5c0f\u4e0d\u80fd\u66f4\u6539\u3002<\/li>\n<li>\u6bcf\u4e2a\u6570\u7ec4\u5143\u7d20\u90fd\u662f\u4e00\u4e2a\u5f15\u7528\uff0c\u6307\u5411\u76f8\u5e94\u7684\u5bf9\u8c61\u3002<\/li>\n<li>\u4f7f\u7528 new \u521b\u5efa\u7684\u5bf9\u8c61\u6570\u7ec4\u9ed8\u8ba4\u521d\u59cb\u5316\u4e3a null\u3002<\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\u5c31\u662fjava\u7528new\u600e\u4e48\u521b\u5efa\u5bf9\u8c61\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\u4f7f\u7528 new \u521b\u5efa\u5bf9\u8c61\u6570\u7ec4\u7684\u8bed\u6cd5\u4e3a\uff1aobjectname[] arrayname = new objectname[size]\uff0c\u5176\u4e2d objectname \u662f\u8981\u521b\u5efa\u7684\u6570\u7ec4\u5143\u7d20\u7684\u7c7b\u540d\uff0carrayname \u662f\u6570\u7ec4\u7684\u540d\u79f0\uff0csize \u662f\u6570\u7ec4\u7684\u5927\u5c0f\u3002 Java \u4f7f\u7528 new \u521b\u5efa\u5bf9\u8c61\u6570\u7ec4 \u95ee\uff1aJava \u4e2d\u5982\u4f55\u4f7f\u7528 new \u521b\u5efa\u5bf9\u8c61\u6570\u7ec4\uff1f \u7b54\uff1aJava \u4e2d\u4f7f\u7528 new \u521b\u5efa\u5bf9\u8c61\u6570\u7ec4\u7684\u8bed\u6cd5\u5982\u4e0b\uff1a ObjectName[] arrayName = new ObjectName[size]; \u767b\u5f55\u540e\u590d\u5236 \u5176\u4e2d\uff0cObjectName \u662f\u8981\u521b\u5efa\u7684\u6570\u7ec4\u5143\u7d20\u7684\u7c7b\u540d\uff0carrayName \u662f\u6570\u7ec4\u7684\u540d\u79f0\uff0csize \u662f\u6570\u7ec4\u7684\u5927\u5c0f\u3002 \u7acb\u5373\u5b66\u4e60\u201c\u201d\uff1b \u5c55\u5f00\u89e3\u7b54\uff1a \u7c7b\u540d\uff1a\u6307\u5b9a\u8981\u521b\u5efa\u7684\u6570\u7ec4\u5143\u7d20\u7684\u7c7b\u3002\u4f8b\u5982\uff0c\u8981\u521b\u5efa String \u6570\u7ec4\uff0c\u7c7b\u540d\u5c31\u662f String\u3002 \u6570\u7ec4\u540d\u79f0\uff1a\u4e3a\u6570\u7ec4\u6307\u5b9a\u4e00\u4e2a\u6807\u8bc6\u7b26\u3002 \u6570\u7ec4\u5927\u5c0f\uff1a\u6307\u5b9a\u6570\u7ec4\u8981\u5305\u542b\u7684\u5143\u7d20\u6570\u91cf\u3002 \u4f8b\u5982\uff1a String[] names = new String[5]; \u767b\u5f55\u540e\u590d\u5236 \u8fd9\u5c06\u521b\u5efa\u4e00\u4e2a\u5305\u542b 5 \u4e2a String \u5143\u7d20\u7684\u6570\u7ec4\uff0c\u540d\u4e3a names\u3002 [&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-65926","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/65926","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=65926"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/65926\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=65926"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=65926"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=65926"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}