{"id":37600,"date":"2024-11-26T12:11:37","date_gmt":"2024-11-26T04:11:37","guid":{"rendered":"https:\/\/fwq.ai\/blog\/37600\/"},"modified":"2024-11-26T12:11:37","modified_gmt":"2024-11-26T04:11:37","slug":"java%e6%80%8e%e4%b9%88%e5%a3%b0%e6%98%8e%e6%95%b0%e7%bb%84%e5%b9%b6%e8%b5%8b%e5%80%bc","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/37600\/","title":{"rendered":"java\u600e\u4e48\u58f0\u660e\u6570\u7ec4\u5e76\u8d4b\u503c"},"content":{"rendered":"<blockquote><p>\n  \u5728 java \u4e2d\uff0c\u58f0\u660e\u548c\u8d4b\u503c\u6570\u7ec4\u7684\u8bed\u6cd5\u4e3a\uff1a\u6570\u636e\u7c7b\u578b[] \u6570\u7ec4\u540d = {\u5143\u7d20 1, \u5143\u7d20 2, &#8230;, \u5143\u7d20 n}\u3002\u9996\u5148\u58f0\u660e\u6570\u7ec4\uff0c\u6307\u5b9a\u7c7b\u578b\u548c\u540d\u79f0\uff1b\u7136\u540e\u901a\u8fc7 {} \u8d4b\u503c\uff0c\u5176\u4e2d\u5143\u7d20\u4ee5\u9017\u53f7\u5206\u9694\u3002\u6570\u7ec4\u7684\u5927\u5c0f\u56fa\u5b9a\uff0c\u5143\u7d20\u7c7b\u578b\u4e0e\u58f0\u660e\u6570\u7ec4\u7c7b\u578b\u5339\u914d\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202411\/13\/2024111307394369896.jpg\" class=\"aligncenter\" title=\"java\u600e\u4e48\u58f0\u660e\u6570\u7ec4\u5e76\u8d4b\u503c\u63d2\u56fe\" alt=\"java\u600e\u4e48\u58f0\u660e\u6570\u7ec4\u5e76\u8d4b\u503c\u63d2\u56fe\" \/><\/p>\n<p><strong>Java \u4e2d\u58f0\u660e\u6570\u7ec4\u5e76\u8d4b\u503c<\/strong><\/p>\n<p>\u5728 Java \u4e2d\uff0c\u58f0\u660e\u548c\u8d4b\u503c\u6570\u7ec4\u7684\u8bed\u6cd5\u5982\u4e0b\uff1a<\/p>\n<pre>\u6570\u636e\u7c7b\u578b[] \u6570\u7ec4\u540d = {\u5143\u7d20 1, \u5143\u7d20 2, ..., \u5143\u7d20 n};<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u58f0\u660e\u6570\u7ec4<\/strong><\/p>\n<p>\u58f0\u660e\u6570\u7ec4\u65f6\uff0c\u9700\u8981\u6307\u5b9a\u6570\u7ec4\u7684\u7c7b\u578b\u548c\u540d\u79f0\u3002\u6570\u7ec4\u7c7b\u578b\u53ef\u4ee5\u662f\u4efb\u4f55\u6709\u6548\u7684 Java \u6570\u636e\u7c7b\u578b\uff0c\u4f8b\u5982 int\u3001String \u6216\u81ea\u5b9a\u4e49\u7c7b\u3002\u6570\u7ec4\u540d\u79f0\u662f\u7528\u6765\u5f15\u7528\u6570\u7ec4\u7684\u7b26\u53f7\u3002<\/p>\n<p><span>\u7acb\u5373\u5b66\u4e60<\/span>\u201c\u201d\uff1b<\/p>\n<p><strong>\u8d4b\u503c\u6570\u7ec4<\/strong><\/p>\n<p>\u58f0\u660e\u6570\u7ec4\u540e\uff0c\u53ef\u4ee5\u901a\u8fc7\u4f7f\u7528\u82b1\u62ec\u53f7 {} \u6765\u8d4b\u503c\u3002\u5927\u62ec\u53f7\u5185\u5305\u542b\u4ee5\u9017\u53f7\u5206\u9694\u7684\u6570\u7ec4\u5143\u7d20\u3002\u5143\u7d20\u53ef\u4ee5\u662f\u4efb\u4f55\u6709\u6548\u7684\u503c\uff0c\u5305\u62ec\u539f\u8bed\u7c7b\u578b\u3001\u5bf9\u8c61\u6216\u5176\u4ed6\u6570\u7ec4\u3002<\/p>\n<p><strong>\u793a\u4f8b<\/strong><\/p>\n<p>\u4ee5\u4e0b\u4ee3\u7801\u58f0\u660e\u4e86\u4e00\u4e2a int \u7c7b\u578b\u7684\u6570\u7ec4\u5e76\u7ed9\u5176\u8d4b\u503c\u4e3a 10 \u4e2a\u5143\u7d20\uff1a<\/p>\n<pre>int[] numbers = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u4ee5\u4e0b\u4ee3\u7801\u58f0\u660e\u4e86\u4e00\u4e2a String \u7c7b\u578b\u7684\u6570\u7ec4\u5e76\u7ed9\u5176\u8d4b\u503c\u4e3a 3 \u4e2a\u5143\u7d20\uff1a<\/p>\n<pre>String[] names = {\"John\", \"Mary\", \"Bob\"};<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u6ce8\u610f\u4e8b\u9879<\/strong><\/p>\n<ul>\n<li>\u6570\u7ec4\u7684\u5927\u5c0f\u662f\u56fa\u5b9a\u7684\uff0c\u5728\u58f0\u660e\u65f6\u6307\u5b9a\uff0c\u4e0d\u80fd\u5728\u4ee5\u540e\u6539\u53d8\u3002<\/li>\n<li>\u6570\u7ec4\u5143\u7d20\u7684\u7c7b\u578b\u5fc5\u987b\u4e0e\u58f0\u660e\u7684\u6570\u7ec4\u7c7b\u578b\u76f8\u5339\u914d\u3002<\/li>\n<li>\u53ef\u4ee5\u4f7f\u7528 new \u64cd\u4f5c\u7b26\u663e\u5f0f\u5730\u521b\u5efa\u6570\u7ec4\uff0c\u4f46\u901a\u5e38\u4e0d\u63a8\u8350\u4f7f\u7528\u8fd9\u79cd\u65b9\u6cd5\u3002<\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\u5c31\u662fjava\u600e\u4e48\u58f0\u660e\u6570\u7ec4\u5e76\u8d4b\u503c\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5728 java \u4e2d\uff0c\u58f0\u660e\u548c\u8d4b\u503c\u6570\u7ec4\u7684\u8bed\u6cd5\u4e3a\uff1a\u6570\u636e\u7c7b\u578b[] \u6570\u7ec4\u540d = {\u5143\u7d20 1, \u5143\u7d20 2, &#8230;, \u5143\u7d20 n}\u3002\u9996\u5148\u58f0\u660e\u6570\u7ec4\uff0c\u6307\u5b9a\u7c7b\u578b\u548c\u540d\u79f0\uff1b\u7136\u540e\u901a\u8fc7 {} \u8d4b\u503c\uff0c\u5176\u4e2d\u5143\u7d20\u4ee5\u9017\u53f7\u5206\u9694\u3002\u6570\u7ec4\u7684\u5927\u5c0f\u56fa\u5b9a\uff0c\u5143\u7d20\u7c7b\u578b\u4e0e\u58f0\u660e\u6570\u7ec4\u7c7b\u578b\u5339\u914d\u3002 Java \u4e2d\u58f0\u660e\u6570\u7ec4\u5e76\u8d4b\u503c \u5728 Java \u4e2d\uff0c\u58f0\u660e\u548c\u8d4b\u503c\u6570\u7ec4\u7684\u8bed\u6cd5\u5982\u4e0b\uff1a \u6570\u636e\u7c7b\u578b[] \u6570\u7ec4\u540d = {\u5143\u7d20 1, \u5143\u7d20 2, &#8230;, \u5143\u7d20 n}; \u767b\u5f55\u540e\u590d\u5236 \u58f0\u660e\u6570\u7ec4 \u58f0\u660e\u6570\u7ec4\u65f6\uff0c\u9700\u8981\u6307\u5b9a\u6570\u7ec4\u7684\u7c7b\u578b\u548c\u540d\u79f0\u3002\u6570\u7ec4\u7c7b\u578b\u53ef\u4ee5\u662f\u4efb\u4f55\u6709\u6548\u7684 Java \u6570\u636e\u7c7b\u578b\uff0c\u4f8b\u5982 int\u3001String \u6216\u81ea\u5b9a\u4e49\u7c7b\u3002\u6570\u7ec4\u540d\u79f0\u662f\u7528\u6765\u5f15\u7528\u6570\u7ec4\u7684\u7b26\u53f7\u3002 \u7acb\u5373\u5b66\u4e60\u201c\u201d\uff1b \u8d4b\u503c\u6570\u7ec4 \u58f0\u660e\u6570\u7ec4\u540e\uff0c\u53ef\u4ee5\u901a\u8fc7\u4f7f\u7528\u82b1\u62ec\u53f7 {} \u6765\u8d4b\u503c\u3002\u5927\u62ec\u53f7\u5185\u5305\u542b\u4ee5\u9017\u53f7\u5206\u9694\u7684\u6570\u7ec4\u5143\u7d20\u3002\u5143\u7d20\u53ef\u4ee5\u662f\u4efb\u4f55\u6709\u6548\u7684\u503c\uff0c\u5305\u62ec\u539f\u8bed\u7c7b\u578b\u3001\u5bf9\u8c61\u6216\u5176\u4ed6\u6570\u7ec4\u3002 \u793a\u4f8b \u4ee5\u4e0b\u4ee3\u7801\u58f0\u660e\u4e86\u4e00\u4e2a int \u7c7b\u578b\u7684\u6570\u7ec4\u5e76\u7ed9\u5176\u8d4b\u503c\u4e3a 10 \u4e2a\u5143\u7d20\uff1a int[] numbers = {1, 2, 3, 4, 5, [&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-37600","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/37600","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=37600"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/37600\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=37600"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=37600"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=37600"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}