{"id":65244,"date":"2025-05-03T14:19:30","date_gmt":"2025-05-03T06:19:30","guid":{"rendered":"https:\/\/fwq.ai\/blog\/65244\/"},"modified":"2025-05-03T14:19:30","modified_gmt":"2025-05-03T06:19:30","slug":"java%e4%b8%ad%e6%95%b0%e7%bb%84%e6%80%8e%e4%b9%88-2","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/65244\/","title":{"rendered":"java\u4e2d\u6570\u7ec4\u600e\u4e48"},"content":{"rendered":"<blockquote><p>\n  java \u4e2d\u521d\u59cb\u5316\u6570\u7ec4\u7684\u6b65\u9aa4\uff1a\u58f0\u660e\u6570\u7ec4\u53d8\u91cf\u3002\u4f7f\u7528 new \u5173\u952e\u5b57\u5206\u914d\u5185\u5b58\u3002\u901a\u8fc7\u7d22\u5f15\u8bbf\u95ee\u548c\u521d\u59cb\u5316\u6570\u7ec4\u5143\u7d20\u3002\u53ef\u4f7f\u7528\u6570\u7ec4\u521d\u59cb\u5316\u5668\u8bbe\u7f6e\u521d\u59cb\u503c\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202411\/12\/2024111214191480364.jpg\" class=\"aligncenter\" title=\"java\u4e2d\u6570\u7ec4\u600e\u4e48\u63d2\u56fe\" alt=\"java\u4e2d\u6570\u7ec4\u600e\u4e48\u63d2\u56fe\" \/><\/p>\n<p><strong>Java \u4e2d\u6570\u7ec4\u5982\u4f55\u521d\u59cb\u5316<\/strong><\/p>\n<p>\u5728 Java \u4e2d\uff0c\u6570\u7ec4\u662f\u4e00\u79cd\u6570\u636e\u7ed3\u6784\uff0c\u7528\u4e8e\u5b58\u50a8\u76f8\u540c\u7c7b\u578b\u5143\u7d20\u7684\u96c6\u5408\u3002\u8981\u521d\u59cb\u5316\u6570\u7ec4\uff0c\u53ef\u4ee5\u6309\u7167\u4ee5\u4e0b\u6b65\u9aa4\u64cd\u4f5c\uff1a<\/p>\n<p><strong>1. \u58f0\u660e\u6570\u7ec4\u53d8\u91cf<\/strong><\/p>\n<pre>int[] arr;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>2. \u4e3a\u6570\u7ec4\u5206\u914d\u5185\u5b58<\/strong><\/p>\n<p><span>\u7acb\u5373\u5b66\u4e60<\/span>\u201c\u201d\uff1b<\/p>\n<p>\u4f7f\u7528 new \u5173\u952e\u5b57\u4e3a\u6570\u7ec4\u5206\u914d\u5185\u5b58\u3002new \u5173\u952e\u5b57\u540e\u9762\u662f\u6570\u636e\u7c7b\u578b\uff0c\u7136\u540e\u662f\u65b9\u62ec\u53f7\uff0c\u5176\u4e2d\u5305\u542b\u6570\u7ec4\u7684\u5927\u5c0f\u3002<\/p>\n<pre>arr = new int[5];<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>3. \u521d\u59cb\u5316\u6570\u7ec4\u5143\u7d20<\/strong><\/p>\n<p>\u4f7f\u7528\u6570\u7ec4\u53d8\u91cf\u548c\u7d22\u5f15\u6765\u8bbf\u95ee\u548c\u521d\u59cb\u5316\u6570\u7ec4\u5143\u7d20\u3002\u6570\u7ec4\u7d22\u5f15\u4ece 0 \u5f00\u59cb\u3002<\/p>\n<pre>arr[0] = 1;\narr[1] = 2;\narr[2] = 3;\narr[3] = 4;\narr[4] = 5;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u521d\u59cb\u5316\u5e26\u6709\u521d\u59cb\u503c\u7684\u6570\u7ec4<\/strong><\/p>\n<p>\u8fd8\u53ef\u4ee5\u4f7f\u7528\u5e26\u6709\u521d\u59cb\u503c\u7684\u6570\u7ec4\u521d\u59cb\u5316\u5668\u6765\u521d\u59cb\u5316\u6570\u7ec4\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0cnew \u5173\u952e\u5b57\u540e\u9762\u662f\u82b1\u62ec\u53f7\uff0c\u5176\u4e2d\u5305\u542b\u5143\u7d20\u5217\u8868\u3002<\/p>\n<pre>int[] arr = {1, 2, 3, 4, 5};<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u6ce8\u610f\u4e8b\u9879\uff1a<\/strong><\/p>\n<ul>\n<li>\u6570\u7ec4\u5927\u5c0f\u5728\u521b\u5efa\u540e\u4e0d\u80fd\u66f4\u6539\u3002<\/li>\n<li>\u5982\u679c\u6570\u7ec4\u5143\u7d20\u672a\u521d\u59cb\u5316\uff0c\u5219\u4f1a\u81ea\u52a8\u521d\u59cb\u5316\u4e3a\u9ed8\u8ba4\u503c\u3002\u5bf9\u4e8e\u6570\u503c\u7c7b\u578b\uff0c\u9ed8\u8ba4\u503c\u4e3a 0\u3002<\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\u5c31\u662fjava\u4e2d\u6570\u7ec4\u600e\u4e48\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\u6570\u7ec4\u7684\u6b65\u9aa4\uff1a\u58f0\u660e\u6570\u7ec4\u53d8\u91cf\u3002\u4f7f\u7528 new \u5173\u952e\u5b57\u5206\u914d\u5185\u5b58\u3002\u901a\u8fc7\u7d22\u5f15\u8bbf\u95ee\u548c\u521d\u59cb\u5316\u6570\u7ec4\u5143\u7d20\u3002\u53ef\u4f7f\u7528\u6570\u7ec4\u521d\u59cb\u5316\u5668\u8bbe\u7f6e\u521d\u59cb\u503c\u3002 Java \u4e2d\u6570\u7ec4\u5982\u4f55\u521d\u59cb\u5316 \u5728 Java \u4e2d\uff0c\u6570\u7ec4\u662f\u4e00\u79cd\u6570\u636e\u7ed3\u6784\uff0c\u7528\u4e8e\u5b58\u50a8\u76f8\u540c\u7c7b\u578b\u5143\u7d20\u7684\u96c6\u5408\u3002\u8981\u521d\u59cb\u5316\u6570\u7ec4\uff0c\u53ef\u4ee5\u6309\u7167\u4ee5\u4e0b\u6b65\u9aa4\u64cd\u4f5c\uff1a 1. \u58f0\u660e\u6570\u7ec4\u53d8\u91cf int[] arr; \u767b\u5f55\u540e\u590d\u5236 2. \u4e3a\u6570\u7ec4\u5206\u914d\u5185\u5b58 \u7acb\u5373\u5b66\u4e60\u201c\u201d\uff1b \u4f7f\u7528 new \u5173\u952e\u5b57\u4e3a\u6570\u7ec4\u5206\u914d\u5185\u5b58\u3002new \u5173\u952e\u5b57\u540e\u9762\u662f\u6570\u636e\u7c7b\u578b\uff0c\u7136\u540e\u662f\u65b9\u62ec\u53f7\uff0c\u5176\u4e2d\u5305\u542b\u6570\u7ec4\u7684\u5927\u5c0f\u3002 arr = new int[5]; \u767b\u5f55\u540e\u590d\u5236 3. \u521d\u59cb\u5316\u6570\u7ec4\u5143\u7d20 \u4f7f\u7528\u6570\u7ec4\u53d8\u91cf\u548c\u7d22\u5f15\u6765\u8bbf\u95ee\u548c\u521d\u59cb\u5316\u6570\u7ec4\u5143\u7d20\u3002\u6570\u7ec4\u7d22\u5f15\u4ece 0 \u5f00\u59cb\u3002 arr[0] = 1; arr[1] = 2; arr[2] = 3; arr[3] = 4; arr[4] = 5; \u767b\u5f55\u540e\u590d\u5236 \u521d\u59cb\u5316\u5e26\u6709\u521d\u59cb\u503c\u7684\u6570\u7ec4 \u8fd8\u53ef\u4ee5\u4f7f\u7528\u5e26\u6709\u521d\u59cb\u503c\u7684\u6570\u7ec4\u521d\u59cb\u5316\u5668\u6765\u521d\u59cb\u5316\u6570\u7ec4\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0cnew \u5173\u952e\u5b57\u540e\u9762\u662f\u82b1\u62ec\u53f7\uff0c\u5176\u4e2d\u5305\u542b\u5143\u7d20\u5217\u8868\u3002 int[] arr = {1, 2, [&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-65244","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/65244","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=65244"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/65244\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=65244"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=65244"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=65244"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}