{"id":40113,"date":"2024-11-26T08:38:09","date_gmt":"2024-11-26T00:38:09","guid":{"rendered":"https:\/\/fwq.ai\/blog\/40113\/"},"modified":"2024-11-26T08:38:09","modified_gmt":"2024-11-26T00:38:09","slug":"java%e6%80%8e%e4%b9%88%e6%8a%8a%e6%95%b0%e7%bb%84a%e7%9a%84%e5%bc%95%e7%94%a8%e8%b5%8b%e7%bb%99b","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/40113\/","title":{"rendered":"java\u600e\u4e48\u628a\u6570\u7ec4a\u7684\u5f15\u7528\u8d4b\u7ed9b"},"content":{"rendered":"<blockquote><p>\n  java \u4e2d\u5c06\u6570\u7ec4\u5f15\u7528\u8d4b\u503c\u7ed9\u53e6\u4e00\u4e2a\u6570\u7ec4\uff1a\u4f7f\u7528\u8d4b\u503c\u8fd0\u7b97\u7b26 (=) \u5c06\u6570\u7ec4\u7684\u5f15\u7528\u76f4\u63a5\u8d4b\u503c\u7ed9\u53e6\u4e00\u4e2a\u6570\u7ec4\u3002\u6b64\u65f6\uff0c\u4e24\u4e2a\u6570\u7ec4\u5747\u6307\u5411\u76f8\u540c\u7684\u5e95\u5c42\u6570\u636e\u7ed3\u6784\uff0c\u5bf9\u5176\u4e2d\u4e00\u4e2a\u6570\u7ec4\u7684\u66f4\u6539\u5c06\u53cd\u6620\u5728\u53e6\u4e00\u4e2a\u6570\u7ec4\u4e2d\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202411\/17\/2024111720304226488.jpg\" class=\"aligncenter\" title=\"java\u600e\u4e48\u628a\u6570\u7ec4a\u7684\u5f15\u7528\u8d4b\u7ed9b\u63d2\u56fe\" alt=\"java\u600e\u4e48\u628a\u6570\u7ec4a\u7684\u5f15\u7528\u8d4b\u7ed9b\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5982\u4f55\u5c06\u6570\u7ec4 a \u7684\u5f15\u7528\u8d4b\u7ed9\u6570\u7ec4 b<\/strong><\/p>\n<p>Java \u4e2d\uff0c\u5c06\u6570\u7ec4\u7684\u5f15\u7528\u8d4b\u503c\u7ed9\u53e6\u4e00\u4e2a\u6570\u7ec4\u975e\u5e38\u7b80\u5355\uff0c\u53ea\u9700\u4f7f\u7528\u8d4b\u503c\u8fd0\u7b97\u7b26 (=)\u3002<\/p>\n<p><strong>\u6b65\u9aa4\uff1a<\/strong><\/p>\n<ol>\n<li>\u58f0\u660e\u4e24\u4e2a\u6570\u7ec4 a \u548c b\u3002<\/li>\n<li>\u8d4b\u503c\u64cd\u4f5c\uff1a\u5c06 a \u7684\u5f15\u7528\u76f4\u63a5\u8d4b\u503c\u7ed9 b\u3002<\/li>\n<\/ol>\n<p><strong>\u8bed\u6cd5\uff1a<\/strong><\/p>\n<p><span>\u7acb\u5373\u5b66\u4e60<\/span>\u201c\u201d\uff1b<\/p>\n<pre>int[] a = {1, 2, 3};\nint[] b = a;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u8bf4\u660e\uff1a<\/strong><\/p>\n<ul>\n<li>\u73b0\u5728\uff0cb \u5f15\u7528\u4e86\u4e0e a \u76f8\u540c\u7684\u6570\u7ec4\u5bf9\u8c61\u3002<\/li>\n<li>\u4efb\u4f55\u5bf9\u6570\u7ec4 a \u7684\u66f4\u6539\u90fd\u5c06\u53cd\u6620\u5728 b \u4e2d\uff0c\u53cd\u4e4b\u4ea6\u7136\u3002<\/li>\n<li>\u7531\u4e8e b \u53ea\u662f a \u7684\u5f15\u7528\uff0c\u56e0\u6b64\u8fd9\u4e24\u4e2a\u6570\u7ec4\u6307\u5411\u540c\u4e00\u4e2a\u5e95\u5c42\u6570\u636e\u7ed3\u6784\u3002<\/li>\n<\/ul>\n<p><strong>\u793a\u4f8b\uff1a<\/strong><\/p>\n<pre>public static void main(String[] args) {\n    int[] a = {1, 2, 3};\n    int[] b = a;\n\n    \/\/ \u5bf9 a \u8fdb\u884c\u66f4\u6539\n    a[0] = 5;\n\n    \/\/ \u66f4\u6539\u53cd\u6620\u5728 b \u4e2d\n    System.out.println(b[0]); \/\/ \u8f93\u51fa\uff1a5\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u6ce8\u610f\uff1a<\/strong><\/p>\n<ul>\n<li>\u4f7f\u7528\u6570\u7ec4\u7684\u5f15\u7528\u65f6\uff0c\u8bf7\u6ce8\u610f\u4e0d\u8981\u8986\u76d6\u539f\u59cb\u6570\u7ec4\u3002<\/li>\n<li>\u5982\u679c\u9700\u8981\u521b\u5efa a \u7684\u4e00\u4e2a\u526f\u672c\uff0c\u53ef\u4ee5\u4f7f\u7528 Arrays.copyOf() \u65b9\u6cd5\u3002<\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\u5c31\u662fjava\u600e\u4e48\u628a\u6570\u7ec4a\u7684\u5f15\u7528\u8d4b\u7ed9b\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\u5c06\u6570\u7ec4\u5f15\u7528\u8d4b\u503c\u7ed9\u53e6\u4e00\u4e2a\u6570\u7ec4\uff1a\u4f7f\u7528\u8d4b\u503c\u8fd0\u7b97\u7b26 (=) \u5c06\u6570\u7ec4\u7684\u5f15\u7528\u76f4\u63a5\u8d4b\u503c\u7ed9\u53e6\u4e00\u4e2a\u6570\u7ec4\u3002\u6b64\u65f6\uff0c\u4e24\u4e2a\u6570\u7ec4\u5747\u6307\u5411\u76f8\u540c\u7684\u5e95\u5c42\u6570\u636e\u7ed3\u6784\uff0c\u5bf9\u5176\u4e2d\u4e00\u4e2a\u6570\u7ec4\u7684\u66f4\u6539\u5c06\u53cd\u6620\u5728\u53e6\u4e00\u4e2a\u6570\u7ec4\u4e2d\u3002 \u5982\u4f55\u5c06\u6570\u7ec4 a \u7684\u5f15\u7528\u8d4b\u7ed9\u6570\u7ec4 b Java \u4e2d\uff0c\u5c06\u6570\u7ec4\u7684\u5f15\u7528\u8d4b\u503c\u7ed9\u53e6\u4e00\u4e2a\u6570\u7ec4\u975e\u5e38\u7b80\u5355\uff0c\u53ea\u9700\u4f7f\u7528\u8d4b\u503c\u8fd0\u7b97\u7b26 (=)\u3002 \u6b65\u9aa4\uff1a \u58f0\u660e\u4e24\u4e2a\u6570\u7ec4 a \u548c b\u3002 \u8d4b\u503c\u64cd\u4f5c\uff1a\u5c06 a \u7684\u5f15\u7528\u76f4\u63a5\u8d4b\u503c\u7ed9 b\u3002 \u8bed\u6cd5\uff1a \u7acb\u5373\u5b66\u4e60\u201c\u201d\uff1b int[] a = {1, 2, 3}; int[] b = a; \u767b\u5f55\u540e\u590d\u5236 \u8bf4\u660e\uff1a \u73b0\u5728\uff0cb \u5f15\u7528\u4e86\u4e0e a \u76f8\u540c\u7684\u6570\u7ec4\u5bf9\u8c61\u3002 \u4efb\u4f55\u5bf9\u6570\u7ec4 a \u7684\u66f4\u6539\u90fd\u5c06\u53cd\u6620\u5728 b \u4e2d\uff0c\u53cd\u4e4b\u4ea6\u7136\u3002 \u7531\u4e8e b \u53ea\u662f a \u7684\u5f15\u7528\uff0c\u56e0\u6b64\u8fd9\u4e24\u4e2a\u6570\u7ec4\u6307\u5411\u540c\u4e00\u4e2a\u5e95\u5c42\u6570\u636e\u7ed3\u6784\u3002 \u793a\u4f8b\uff1a public static void main(String[] args) { [&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-40113","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/40113","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=40113"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/40113\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=40113"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=40113"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=40113"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}