{"id":64732,"date":"2025-05-03T15:25:01","date_gmt":"2025-05-03T07:25:01","guid":{"rendered":"https:\/\/fwq.ai\/blog\/64732\/"},"modified":"2025-05-03T15:25:01","modified_gmt":"2025-05-03T07:25:01","slug":"java-%e9%9d%99%e6%80%81%e5%88%9d%e5%a7%8b%e5%8c%96%ef%bc%9a%e4%b8%ba%e4%bb%80%e4%b9%88%e6%95%b0%e7%bb%84%e5%88%9d%e5%a7%8b%e5%8c%96%e5%bf%85%e9%a1%bb%e4%bd%bf%e7%94%a8-new-%e5%85%b3%e9%94%ae-2","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/64732\/","title":{"rendered":"Java \u9759\u6001\u521d\u59cb\u5316\uff1a\u4e3a\u4ec0\u4e48\u6570\u7ec4\u521d\u59cb\u5316\u5fc5\u987b\u4f7f\u7528 new \u5173\u952e\u5b57\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173070018362483.jpg\" class=\"aligncenter\" title=\"Java \u9759\u6001\u521d\u59cb\u5316\uff1a\u4e3a\u4ec0\u4e48\u6570\u7ec4\u521d\u59cb\u5316\u5fc5\u987b\u4f7f\u7528 new \u5173\u952e\u5b57\uff1f\u63d2\u56fe\" alt=\"Java \u9759\u6001\u521d\u59cb\u5316\uff1a\u4e3a\u4ec0\u4e48\u6570\u7ec4\u521d\u59cb\u5316\u5fc5\u987b\u4f7f\u7528 new \u5173\u952e\u5b57\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>java \u9759\u6001\u521d\u59cb\u5316\uff1anew \u4e0e\u5426\u7684\u5965\u79d8<\/strong><\/p>\n<p>\u5728 java \u4e2d\uff0c\u4f7f\u7528\u9759\u6001\u521d\u59cb\u5316\u5668\u4e3a\u6570\u7ec4\u5206\u914d\u5185\u5b58\u6709\u591a\u79cd\u65b9\u5f0f\u3002\u5176\u4e2d\uff0c\u4f7f\u7528 new \u5173\u952e\u5b57\u548c\u4e0d\u4f7f\u7528 new \u5173\u952e\u5b57\u7684\u4e24\u79cd\u65b9\u5f0f\u770b\u4f3c\u76f8\u4f3c\uff0c\u4f46\u5b9e\u9645\u4e0a\u5b58\u5728\u5fae\u5999\u7684\u3002<\/p>\n<p><strong>\u4f7f\u7528 new \u5173\u952e\u5b57<\/strong><\/p>\n<p>int[] arr = new int[]{3, 3, 5, 9, 11};<\/p>\n<p><span>\u7acb\u5373\u5b66\u4e60<\/span>\u201c\u201d\uff1b<\/p>\n<p>\u4f7f\u7528 new \u5173\u952e\u5b57\u65f6\uff0c\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u6570\u7ec4\u5e76\u5c06\u5176\u5206\u914d\u7ed9 arr \u53d8\u91cf\u3002\u8fd9\u79cd\u65b9\u5f0f\u4f1a\u663e\u5f0f\u5730\u521b\u5efa\u8be5\u6570\u7ec4\uff0c\u5e76\u4e14\u53ef\u4ee5\u4f7f\u7528\u6b64\u53e5\u6cd5\u521d\u59cb\u5316\u6570\u7ec4\u4e2d\u7684\u5143\u7d20\u3002<\/p>\n<p><strong>\u4e0d\u4f7f\u7528 new \u5173\u952e\u5b57<\/strong><\/p>\n<p>int[] arr = {3, 3, 5, 9, 11};<\/p>\n<p>\u4e0d\u4f7f\u7528 new \u5173\u952e\u5b57\u65f6\uff0c\u5c1d\u8bd5\u901a\u8fc7\u8bed\u6cd5\u7cd6\u8bed\u6cd5\u5bf9 arr \u53d8\u91cf\u8fdb\u884c\u8d4b\u503c\u3002\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u7f16\u8bd1\u5668\u4f1a\u5c06\u6b64\u8bed\u6cd5\u89e3\u91ca\u4e3a\u6570\u7ec4\u7684\u58f0\u660e\u3001\u5206\u914d\u548c\u521d\u59cb\u5316\u3002\u7136\u800c\uff0c\u8fd9\u79cd\u8bed\u6cd5\u5b9e\u9645\u4e0a\u5e76\u4e0d\u662f java \u6240\u652f\u6301\u7684\uff0c\u56e0\u6b64\u4f1a\u5f15\u53d1\u7f16\u8bd1\u65f6\u9519\u8bef\u3002\u8be5\u9519\u8bef\u6d88\u606f\u663e\u793a\uff1a\u201c\u6570\u7ec4\u521d\u59cb\u5316\u5668\u7684\u5143\u7d20\u503c\u5fc5\u987b\u4e3a\u5e38\u91cf\u8868\u8fbe\u5f0f\u201d\u3002<\/p>\n<p><strong>\u533a\u522b\u539f\u56e0<\/strong><\/p>\n<p>\u867d\u7136\u4e0d\u4f7f\u7528 new \u5173\u952e\u5b57\u65f6\u7f16\u8bd1\u5668\u4f1a\u5c1d\u8bd5\u5c06\u5176\u89e3\u91ca\u4e3a\u8d4b\u503c\uff0c\u4f46\u5b9e\u9645\u4e0a\u8be5\u64cd\u4f5c\u662f\u4e0d\u5408\u6cd5\u7684\u3002java \u4e2d\u6570\u7ec4\u7684\u8d4b\u503c\u8bed\u6cd5\u5982\u4e0b\uff1a<\/p>\n<pre>arrayName = new arrayType[size];<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u56e0\u6b64\uff0c\u4e0d\u4f7f\u7528 new \u5173\u952e\u5b57\u7684\u8bed\u6cd5 arr = {3, 3, 5, 9, 11}; \u5b9e\u9645\u4e0a\u8bd5\u56fe\u5c06\u4e00\u4e2a\u6570\u7ec4\u8d4b\u503c\u7ed9\u53e6\u4e00\u4e2a\u6570\u7ec4\uff0c\u8fd9\u662f\u4e0d\u652f\u6301\u7684\u3002\u53ea\u6709\u4f7f\u7528 new \u5173\u952e\u5b57\u663e\u5f0f\u521b\u5efa\u65b0\u7684\u6570\u7ec4\uff0c\u624d\u80fd\u6210\u529f\u521d\u59cb\u5316\u6570\u7ec4\u3002<\/p>\n<p><strong>\u7ed3\u8bba<\/strong><\/p>\n<p>\u7efc\u4e0a\u6240\u8ff0\uff0c\u867d\u7136\u4f7f\u7528 new \u5173\u952e\u5b57\u548c\u4e0d\u4f7f\u7528 new \u5173\u952e\u5b57\u5bf9\u6570\u7ec4\u8fdb\u884c\u9759\u6001\u521d\u59cb\u5316\u7684\u8bed\u6cd5\u7c7b\u4f3c\uff0c\u4f46\u5b83\u4eec\u5728\u672c\u8d28\u4e0a\u662f\u6709\u533a\u522b\u7684\u3002\u4f7f\u7528 new \u5173\u952e\u5b57\u4f1a\u663e\u5f0f\u521b\u5efa\u5e76\u521d\u59cb\u5316\u6570\u7ec4\uff0c\u800c\u5982\u679c\u4e0d\u4f7f\u7528 new \u5173\u952e\u5b57\uff0c\u5219\u7f16\u8bd1\u5668\u4f1a\u5c1d\u8bd5\u8fdb\u884c\u65e0\u6548\u7684\u8d4b\u503c\uff0c\u5bfc\u81f4\u7f16\u8bd1\u65f6\u9519\u8bef\u3002\u56e0\u6b64\uff0c\u5728\u8fdb\u884c\u9759\u6001\u6570\u7ec4\u521d\u59cb\u5316\u65f6\uff0c\u8bf7\u59cb\u7ec8\u4f7f\u7528 new \u5173\u952e\u5b57\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fJava \u9759\u6001\u521d\u59cb\u5316\uff1a\u4e3a\u4ec0\u4e48\u6570\u7ec4\u521d\u59cb\u5316\u5fc5\u987b\u4f7f\u7528 new \u5173\u952e\u5b57\uff1f\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 \u9759\u6001\u521d\u59cb\u5316\uff1anew \u4e0e\u5426\u7684\u5965\u79d8 \u5728 java \u4e2d\uff0c\u4f7f\u7528\u9759\u6001\u521d\u59cb\u5316\u5668\u4e3a\u6570\u7ec4\u5206\u914d\u5185\u5b58\u6709\u591a\u79cd\u65b9\u5f0f\u3002\u5176\u4e2d\uff0c\u4f7f\u7528 new \u5173\u952e\u5b57\u548c\u4e0d\u4f7f\u7528 new \u5173\u952e\u5b57\u7684\u4e24\u79cd\u65b9\u5f0f\u770b\u4f3c\u76f8\u4f3c\uff0c\u4f46\u5b9e\u9645\u4e0a\u5b58\u5728\u5fae\u5999\u7684\u3002 \u4f7f\u7528 new \u5173\u952e\u5b57 int[] arr = new int[]{3, 3, 5, 9, 11}; \u7acb\u5373\u5b66\u4e60\u201c\u201d\uff1b \u4f7f\u7528 new \u5173\u952e\u5b57\u65f6\uff0c\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u6570\u7ec4\u5e76\u5c06\u5176\u5206\u914d\u7ed9 arr \u53d8\u91cf\u3002\u8fd9\u79cd\u65b9\u5f0f\u4f1a\u663e\u5f0f\u5730\u521b\u5efa\u8be5\u6570\u7ec4\uff0c\u5e76\u4e14\u53ef\u4ee5\u4f7f\u7528\u6b64\u53e5\u6cd5\u521d\u59cb\u5316\u6570\u7ec4\u4e2d\u7684\u5143\u7d20\u3002 \u4e0d\u4f7f\u7528 new \u5173\u952e\u5b57 int[] arr = {3, 3, 5, 9, 11}; \u4e0d\u4f7f\u7528 new \u5173\u952e\u5b57\u65f6\uff0c\u5c1d\u8bd5\u901a\u8fc7\u8bed\u6cd5\u7cd6\u8bed\u6cd5\u5bf9 arr \u53d8\u91cf\u8fdb\u884c\u8d4b\u503c\u3002\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u7f16\u8bd1\u5668\u4f1a\u5c06\u6b64\u8bed\u6cd5\u89e3\u91ca\u4e3a\u6570\u7ec4\u7684\u58f0\u660e\u3001\u5206\u914d\u548c\u521d\u59cb\u5316\u3002\u7136\u800c\uff0c\u8fd9\u79cd\u8bed\u6cd5\u5b9e\u9645\u4e0a\u5e76\u4e0d\u662f java \u6240\u652f\u6301\u7684\uff0c\u56e0\u6b64\u4f1a\u5f15\u53d1\u7f16\u8bd1\u65f6\u9519\u8bef\u3002\u8be5\u9519\u8bef\u6d88\u606f\u663e\u793a\uff1a\u201c\u6570\u7ec4\u521d\u59cb\u5316\u5668\u7684\u5143\u7d20\u503c\u5fc5\u987b\u4e3a\u5e38\u91cf\u8868\u8fbe\u5f0f\u201d\u3002 \u533a\u522b\u539f\u56e0 \u867d\u7136\u4e0d\u4f7f\u7528 new \u5173\u952e\u5b57\u65f6\u7f16\u8bd1\u5668\u4f1a\u5c1d\u8bd5\u5c06\u5176\u89e3\u91ca\u4e3a\u8d4b\u503c\uff0c\u4f46\u5b9e\u9645\u4e0a\u8be5\u64cd\u4f5c\u662f\u4e0d\u5408\u6cd5\u7684\u3002java \u4e2d\u6570\u7ec4\u7684\u8d4b\u503c\u8bed\u6cd5\u5982\u4e0b\uff1a arrayName = new arrayType[size]; [&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-64732","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/64732","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=64732"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/64732\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=64732"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=64732"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=64732"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}