{"id":65657,"date":"2025-05-03T09:30:51","date_gmt":"2025-05-03T01:30:51","guid":{"rendered":"https:\/\/fwq.ai\/blog\/65657\/"},"modified":"2025-05-03T09:30:51","modified_gmt":"2025-05-03T01:30:51","slug":"java%e6%9e%84%e9%80%a0%e7%9a%84%e6%95%b0%e7%bb%84%e6%80%8e%e4%b9%88%e8%b5%8b%e5%80%bc-2","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/65657\/","title":{"rendered":"java\u6784\u9020\u7684\u6570\u7ec4\u600e\u4e48\u8d4b\u503c"},"content":{"rendered":"<blockquote><p>\n  java\u4e2d\u53ef\u901a\u8fc7\u58f0\u660e\u548c\u521d\u59cb\u5316\u4e24\u79cd\u65b9\u5f0f\u6784\u9020\u6570\u7ec4\u3002\u6570\u7ec4\u8d4b\u503c\u53ef\u9010\u4e2a\u5143\u7d20\u8d4b\u503c\u6216\u4f7f\u7528\u6570\u7ec4\u8d4b\u503c\uff0c\u540e\u8005\u4f1a\u8986\u76d6\u539f\u59cb\u6570\u7ec4\u503c\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202411\/13\/2024111306362594360.jpg\" class=\"aligncenter\" title=\"java\u6784\u9020\u7684\u6570\u7ec4\u600e\u4e48\u8d4b\u503c\u63d2\u56fe\" alt=\"java\u6784\u9020\u7684\u6570\u7ec4\u600e\u4e48\u8d4b\u503c\u63d2\u56fe\" \/><\/p>\n<p><strong>Java\u4e2d\u6784\u9020\u6570\u7ec4\u5e76\u8d4b\u503c<\/strong><\/p>\n<p>\u5728Java\u4e2d\uff0c\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u4e24\u79cd\u65b9\u5f0f\u6784\u9020\u6570\u7ec4\uff1a<\/p>\n<p><strong>1. \u6570\u7ec4\u58f0\u660e<\/strong><\/p>\n<pre>int[] arr = new int[5];<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u5176\u4e2d\uff0cnew\u8fd0\u7b97\u7b26\u521b\u5efa\u4e86\u4e00\u4e2a\u6307\u5b9a\u957f\u5ea6\u7684\u65b0\u6570\u7ec4\uff0cint\u6307\u5b9a\u6570\u7ec4\u7684\u5143\u7d20\u7c7b\u578b\u3002<\/p>\n<p><span>\u7acb\u5373\u5b66\u4e60<\/span>\u201c\u201d\uff1b<\/p>\n<p><strong>2. \u6570\u7ec4\u521d\u59cb\u5316<\/strong><\/p>\n<pre>int[] arr = {1, 2, 3, 4, 5};<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u8fd9\u5c06\u521b\u5efa\u4e00\u4e2a\u5305\u542b\u9884\u5b9a\u4e49\u503c\u7684\u6570\u7ec4\u3002<\/p>\n<p><strong>\u8d4b\u503c<\/strong><\/p>\n<p>\u5728\u6784\u9020\u6570\u7ec4\u540e\uff0c\u53ef\u4ee5\u9010\u4e2a\u5143\u7d20\u6216\u4f7f\u7528\u6570\u7ec4\u8d4b\u503c\u5bf9\u5176\u8fdb\u884c\u8d4b\u503c\u3002<\/p>\n<p><strong>\u9010\u4e2a\u5143\u7d20\u8d4b\u503c<\/strong><\/p>\n<pre>\/\/ \u9010\u4e2a\u5143\u7d20\u8d4b\u503c\narr[0] = 10;\narr[1] = 20;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u4f7f\u7528\u6570\u7ec4\u8d4b\u503c<\/strong><\/p>\n<pre>\/\/ \u4f7f\u7528\u6570\u7ec4\u8d4b\u503c\nint[] newArr = new int[] {10, 20, 30, 40, 50};\narr = newArr;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u6570\u7ec4\u8d4b\u503c\u4f1a\u8986\u76d6\u539f\u59cb\u6570\u7ec4\u4e2d\u7684\u503c\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fjava\u6784\u9020\u7684\u6570\u7ec4\u600e\u4e48\u8d4b\u503c\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\u53ef\u901a\u8fc7\u58f0\u660e\u548c\u521d\u59cb\u5316\u4e24\u79cd\u65b9\u5f0f\u6784\u9020\u6570\u7ec4\u3002\u6570\u7ec4\u8d4b\u503c\u53ef\u9010\u4e2a\u5143\u7d20\u8d4b\u503c\u6216\u4f7f\u7528\u6570\u7ec4\u8d4b\u503c\uff0c\u540e\u8005\u4f1a\u8986\u76d6\u539f\u59cb\u6570\u7ec4\u503c\u3002 Java\u4e2d\u6784\u9020\u6570\u7ec4\u5e76\u8d4b\u503c \u5728Java\u4e2d\uff0c\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u4e24\u79cd\u65b9\u5f0f\u6784\u9020\u6570\u7ec4\uff1a 1. \u6570\u7ec4\u58f0\u660e int[] arr = new int[5]; \u767b\u5f55\u540e\u590d\u5236 \u5176\u4e2d\uff0cnew\u8fd0\u7b97\u7b26\u521b\u5efa\u4e86\u4e00\u4e2a\u6307\u5b9a\u957f\u5ea6\u7684\u65b0\u6570\u7ec4\uff0cint\u6307\u5b9a\u6570\u7ec4\u7684\u5143\u7d20\u7c7b\u578b\u3002 \u7acb\u5373\u5b66\u4e60\u201c\u201d\uff1b 2. \u6570\u7ec4\u521d\u59cb\u5316 int[] arr = {1, 2, 3, 4, 5}; \u767b\u5f55\u540e\u590d\u5236 \u8fd9\u5c06\u521b\u5efa\u4e00\u4e2a\u5305\u542b\u9884\u5b9a\u4e49\u503c\u7684\u6570\u7ec4\u3002 \u8d4b\u503c \u5728\u6784\u9020\u6570\u7ec4\u540e\uff0c\u53ef\u4ee5\u9010\u4e2a\u5143\u7d20\u6216\u4f7f\u7528\u6570\u7ec4\u8d4b\u503c\u5bf9\u5176\u8fdb\u884c\u8d4b\u503c\u3002 \u9010\u4e2a\u5143\u7d20\u8d4b\u503c \/\/ \u9010\u4e2a\u5143\u7d20\u8d4b\u503c arr[0] = 10; arr[1] = 20; \u767b\u5f55\u540e\u590d\u5236 \u4f7f\u7528\u6570\u7ec4\u8d4b\u503c \/\/ \u4f7f\u7528\u6570\u7ec4\u8d4b\u503c int[] newArr = new int[] {10, 20, 30, 40, 50}; arr = newArr; \u767b\u5f55\u540e\u590d\u5236 \u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u6570\u7ec4\u8d4b\u503c\u4f1a\u8986\u76d6\u539f\u59cb\u6570\u7ec4\u4e2d\u7684\u503c\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-65657","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/65657","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=65657"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/65657\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=65657"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=65657"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=65657"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}