{"id":37675,"date":"2024-11-26T16:30:25","date_gmt":"2024-11-26T08:30:25","guid":{"rendered":"https:\/\/fwq.ai\/blog\/37675\/"},"modified":"2024-11-26T16:30:25","modified_gmt":"2024-11-26T08:30:25","slug":"java-%e6%95%b0%e7%bb%84%e5%9e%8b%e5%af%b9%e8%b1%a1%e6%80%8e%e4%b9%88%e8%b5%8b%e5%80%bc","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/37675\/","title":{"rendered":"java \u6570\u7ec4\u578b\u5bf9\u8c61\u600e\u4e48\u8d4b\u503c"},"content":{"rendered":"<blockquote><p>\n  java \u4e2d\u6570\u7ec4\u578b\u5bf9\u8c61\u7684\u8d4b\u503c\u65b9\u5f0f\u5305\u62ec\uff1a\u76f4\u63a5\u8d4b\u503c\u4f7f\u7528\u6570\u7ec4\u521d\u59cb\u5316\u5668\u4f7f\u7528\u5faa\u73af\u590d\u5236\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202411\/13\/2024111308484020836.jpg\" class=\"aligncenter\" title=\"java \u6570\u7ec4\u578b\u5bf9\u8c61\u600e\u4e48\u8d4b\u503c\u63d2\u56fe\" alt=\"java \u6570\u7ec4\u578b\u5bf9\u8c61\u600e\u4e48\u8d4b\u503c\u63d2\u56fe\" \/><\/p>\n<p><strong>Java \u6570\u7ec4\u578b\u5bf9\u8c61\u7684\u8d4b\u503c<\/strong><\/p>\n<p><strong>\u5982\u4f55\u8d4b\u503c\uff1f<\/strong><\/p>\n<p>Java \u4e2d\uff0c\u6570\u7ec4\u578b\u5bf9\u8c61\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u65b9\u5f0f\u8d4b\u503c\uff1a<\/p>\n<ul>\n<li>\u76f4\u63a5\u8d4b\u503c<\/li>\n<li>\u4f7f\u7528\u6570\u7ec4\u521d\u59cb\u5316\u5668<\/li>\n<li>\u4f7f\u7528\u5faa\u73af\u590d\u5236<\/li>\n<\/ul>\n<p><strong>\u8be6\u7ec6\u8bf4\u660e\uff1a<\/strong><\/p>\n<p><span>\u7acb\u5373\u5b66\u4e60<\/span>\u201c\u201d\uff1b<\/p>\n<p><strong>\u76f4\u63a5\u8d4b\u503c<\/strong><\/p>\n<p>\u76f4\u63a5\u8d4b\u503c\u662f\u6700\u7b80\u5355\u7684\u65b9\u5f0f\uff0c\u53ef\u4ee5\u901a\u8fc7\u7b49\u53f7(=)\u8fd0\u7b97\u7b26\u5c06\u4e00\u4e2a\u6570\u7ec4\u5bf9\u8c61\u76f4\u63a5\u8d4b\u503c\u7ed9\u53e6\u4e00\u4e2a\u6570\u7ec4\u5bf9\u8c61\uff1a<\/p>\n<pre>int[] arr1 = {1, 2, 3};\nint[] arr2 = arr1; \/\/arr2 \u5f15\u7528 arr1 \u6240\u6307\u5411\u7684\u6570\u7ec4<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u6570\u7ec4\u521d\u59cb\u5316\u5668<\/strong><\/p>\n<p>\u6570\u7ec4\u521d\u59cb\u5316\u5668\u4f7f\u7528\u5927\u62ec\u53f7 {} \u521d\u59cb\u5316\u6570\u7ec4\u5143\u7d20\uff1a<\/p>\n<pre>int[] arr1 = {1, 2, 3};\nint[] arr2 = new int[]{1, 2, 3}; \/\/\u7b49\u4ef7\u4e8e arr1<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u4f7f\u7528\u5faa\u73af\u590d\u5236<\/strong><\/p>\n<p>\u4f7f\u7528\u5faa\u73af\u53ef\u4ee5\u5c06\u4e00\u4e2a\u6570\u7ec4\u5143\u7d20\u9010\u4e00\u590d\u5236\u5230\u53e6\u4e00\u4e2a\u6570\u7ec4\u4e2d\uff1a<\/p>\n<pre>int[] arr1 = {1, 2, 3};\nint[] arr2 = new int[arr1.length];\n\nfor (int i = 0; i &lt; arr1.length; i++) {\n    arr2[i] = arr1[i];\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong><\/strong><\/p>\n<ul>\n<li>\u4f7f\u7528\u6570\u7ec4\u521d\u59cb\u5316\u5668\u548c\u4f7f\u7528\u5faa\u73af\u590d\u5236\u521b\u5efa\u7684\u65b0\u6570\u7ec4\u4e0e\u539f\u59cb\u6570\u7ec4\u662f\u72ec\u7acb\u7684\u3002<\/li>\n<li>\u800c\u76f4\u63a5\u8d4b\u503c\u53ea\u662f\u5c06\u65b0\u53d8\u91cf\u6307\u5411\u539f\u59cb\u6570\u7ec4\uff0c\u65b0\u53d8\u91cf\u5bf9\u6570\u7ec4\u7684\u4fee\u6539\u4e5f\u4f1a\u5f71\u54cd\u5230\u539f\u59cb\u6570\u7ec4\u3002<\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\u5c31\u662fjava \u6570\u7ec4\u578b\u5bf9\u8c61\u600e\u4e48\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>java \u4e2d\u6570\u7ec4\u578b\u5bf9\u8c61\u7684\u8d4b\u503c\u65b9\u5f0f\u5305\u62ec\uff1a\u76f4\u63a5\u8d4b\u503c\u4f7f\u7528\u6570\u7ec4\u521d\u59cb\u5316\u5668\u4f7f\u7528\u5faa\u73af\u590d\u5236 Java \u6570\u7ec4\u578b\u5bf9\u8c61\u7684\u8d4b\u503c \u5982\u4f55\u8d4b\u503c\uff1f Java \u4e2d\uff0c\u6570\u7ec4\u578b\u5bf9\u8c61\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u65b9\u5f0f\u8d4b\u503c\uff1a \u76f4\u63a5\u8d4b\u503c \u4f7f\u7528\u6570\u7ec4\u521d\u59cb\u5316\u5668 \u4f7f\u7528\u5faa\u73af\u590d\u5236 \u8be6\u7ec6\u8bf4\u660e\uff1a \u7acb\u5373\u5b66\u4e60\u201c\u201d\uff1b \u76f4\u63a5\u8d4b\u503c \u76f4\u63a5\u8d4b\u503c\u662f\u6700\u7b80\u5355\u7684\u65b9\u5f0f\uff0c\u53ef\u4ee5\u901a\u8fc7\u7b49\u53f7(=)\u8fd0\u7b97\u7b26\u5c06\u4e00\u4e2a\u6570\u7ec4\u5bf9\u8c61\u76f4\u63a5\u8d4b\u503c\u7ed9\u53e6\u4e00\u4e2a\u6570\u7ec4\u5bf9\u8c61\uff1a int[] arr1 = {1, 2, 3}; int[] arr2 = arr1; \/\/arr2 \u5f15\u7528 arr1 \u6240\u6307\u5411\u7684\u6570\u7ec4 \u767b\u5f55\u540e\u590d\u5236 \u6570\u7ec4\u521d\u59cb\u5316\u5668 \u6570\u7ec4\u521d\u59cb\u5316\u5668\u4f7f\u7528\u5927\u62ec\u53f7 {} \u521d\u59cb\u5316\u6570\u7ec4\u5143\u7d20\uff1a int[] arr1 = {1, 2, 3}; int[] arr2 = new int[]{1, 2, 3}; \/\/\u7b49\u4ef7\u4e8e arr1 \u767b\u5f55\u540e\u590d\u5236 \u4f7f\u7528\u5faa\u73af\u590d\u5236 \u4f7f\u7528\u5faa\u73af\u53ef\u4ee5\u5c06\u4e00\u4e2a\u6570\u7ec4\u5143\u7d20\u9010\u4e00\u590d\u5236\u5230\u53e6\u4e00\u4e2a\u6570\u7ec4\u4e2d\uff1a int[] arr1 = {1, [&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-37675","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/37675","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=37675"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/37675\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=37675"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=37675"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=37675"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}