{"id":65299,"date":"2025-05-03T12:46:47","date_gmt":"2025-05-03T04:46:47","guid":{"rendered":"https:\/\/fwq.ai\/blog\/65299\/"},"modified":"2025-05-03T12:46:47","modified_gmt":"2025-05-03T04:46:47","slug":"java%e6%95%b0%e7%bb%84%e6%80%8e%e4%b9%88%e4%bc%a0%e5%9c%b0%e5%9d%80-2","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/65299\/","title":{"rendered":"java\u6570\u7ec4\u600e\u4e48\u4f20\u5730\u5740"},"content":{"rendered":"<blockquote><p>\n  \u5728 java \u4e2d\uff0c\u6570\u7ec4\u53c2\u6570\u4f20\u9012\u7684\u662f\u5f15\u7528\uff0c\u5141\u8bb8\u65b9\u6cd5\u8bbf\u95ee\u548c\u4fee\u6539\u6570\u7ec4\u5185\u5bb9\u3002\u6b64\u5916\uff0c\u6d45\u62f7\u8d1d\u521b\u5efa\u5bf9\u540c\u4e00\u6570\u7ec4\u5bf9\u8c61\u7684\u5f15\u7528\uff0c\u800c\u6df1\u62f7\u8d1d\u521b\u5efa\u4e00\u4e2a\u65b0\u6570\u7ec4\u5e76\u590d\u5236\u539f\u59cb\u6570\u7ec4\u7684\u5185\u5bb9\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202411\/12\/2024111219183978917.jpg\" class=\"aligncenter\" title=\"java\u6570\u7ec4\u600e\u4e48\u4f20\u5730\u5740\u63d2\u56fe\" alt=\"java\u6570\u7ec4\u600e\u4e48\u4f20\u5730\u5740\u63d2\u56fe\" \/><\/p>\n<p><strong>Java \u6570\u7ec4\u5982\u4f55\u4f20\u9012\u5730\u5740<\/strong><\/p>\n<p>\u5728 Java \u4e2d\uff0c\u6570\u7ec4\u672c\u8d28\u4e0a\u662f\u5bf9\u8c61\uff0c\u4f46\u5b83\u4eec\u4e5f\u662f\u5f15\u7528\u7c7b\u578b\u3002\u8fd9\u610f\u5473\u7740\u5b83\u4eec\u5b58\u50a8\u5bf9\u5b9e\u9645\u6570\u7ec4\u5185\u5bb9\u7684\u5f15\u7528\uff0c\u800c\u4e0d\u662f\u5185\u5bb9\u672c\u8eab\u3002\u5f53\u6211\u4eec\u5c06\u4e00\u4e2a\u6570\u7ec4\u53c2\u6570\u4f20\u9012\u7ed9\u4e00\u4e2a\u65b9\u6cd5\u65f6\uff0c\u5b9e\u9645\u4e0a\u662f\u4f20\u9012\u4e86\u8be5\u6570\u7ec4\u7684\u5f15\u7528\u3002<\/p>\n<p><strong>\u4f20\u9012\u5f15\u7528<\/strong><\/p>\n<p>\u5f53\u6211\u4eec\u5c06\u4e00\u4e2a\u6570\u7ec4\u4f5c\u4e3a\u53c2\u6570\u4f20\u9012\u7ed9\u4e00\u4e2a\u65b9\u6cd5\u65f6\uff0c\u65b9\u6cd5\u4f1a\u6536\u5230\u8be5\u6570\u7ec4\u7684\u5f15\u7528\u3002\u8fd9\u610f\u5473\u7740\u8be5\u65b9\u6cd5\u53ef\u4ee5\u8bbf\u95ee\u5e76\u4fee\u6539\u6570\u7ec4\u7684\u5185\u5bb9\uff0c\u4f46\u4e0d\u80fd\u4fee\u6539\u6570\u7ec4\u672c\u8eab\u7684\u957f\u5ea6\u6216\u7c7b\u578b\u3002<\/p>\n<p><span>\u7acb\u5373\u5b66\u4e60<\/span>\u201c\u201d\uff1b<\/p>\n<pre>public static void modifyArray(int[] arr) {\n    arr[0] = 10;\n}\n\npublic static void main(String[] args) {\n    int[] arr = {1, 2, 3};\n    modifyArray(arr);\n    System.out.println(Arrays.toString(arr)); \/\/ \u8f93\u51fa\uff1a[10, 2, 3]\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u6d45\u62f7\u8d1d\u548c\u6df1\u62f7\u8d1d<\/strong><\/p>\n<p><strong>\u6d45\u62f7\u8d1d\uff1a<\/strong>\u5f53\u6211\u4eec\u4f7f\u7528\u8d4b\u503c\u8fd0\u7b97\u7b26\uff08=\uff09\u5c06\u4e00\u4e2a\u6570\u7ec4\u5206\u914d\u7ed9\u53e6\u4e00\u4e2a\u53d8\u91cf\u65f6\uff0c\u6211\u4eec\u521b\u5efa\u4e86\u8be5\u6570\u7ec4\u7684\u6d45\u62f7\u8d1d\u3002\u6d45\u62f7\u8d1d\u5c06\u4e24\u4e2a\u53d8\u91cf\u6307\u5411\u540c\u4e00\u6570\u7ec4\u5bf9\u8c61\u3002\u5bf9\u5176\u4e2d\u4e00\u4e2a\u6570\u7ec4\u6240\u505a\u7684\u4efb\u4f55\u66f4\u6539\u90fd\u4f1a\u5f71\u54cd\u53e6\u4e00\u4e2a\u6570\u7ec4\u3002<\/p>\n<pre>int[] arr1 = {1, 2, 3};\nint[] arr2 = arr1; \/\/ \u6d45\u62f7\u8d1d\n\narr1[0] = 10;\nSystem.out.println(Arrays.toString(arr2)); \/\/ \u8f93\u51fa\uff1a[10, 2, 3]<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u6df1\u62f7\u8d1d\uff1a<\/strong>\u6df1\u62f7\u8d1d\u521b\u5efa\u4e00\u4e2a\u65b0\u6570\u7ec4\u5bf9\u8c61\u5e76\u590d\u5236\u539f\u59cb\u6570\u7ec4\u7684\u5185\u5bb9\u5230\u8be5\u65b0\u6570\u7ec4\u4e2d\u3002\u4e24\u4e2a\u6570\u7ec4\u662f\u72ec\u7acb\u7684\uff0c\u5bf9\u5176\u4e2d\u4e00\u4e2a\u6570\u7ec4\u6240\u505a\u7684\u66f4\u6539\u4e0d\u4f1a\u5f71\u54cd\u53e6\u4e00\u4e2a\u6570\u7ec4\u3002<\/p>\n<pre>int[] arr1 = {1, 2, 3};\nint[] arr2 = Arrays.copyOf(arr1, arr1.length); \/\/ \u6df1\u62f7\u8d1d\n\narr1[0] = 10;\nSystem.out.println(Arrays.toString(arr2)); \/\/ \u8f93\u51fa\uff1a[1, 2, 3]<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fjava\u6570\u7ec4\u600e\u4e48\u4f20\u5730\u5740\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>\u5728 java \u4e2d\uff0c\u6570\u7ec4\u53c2\u6570\u4f20\u9012\u7684\u662f\u5f15\u7528\uff0c\u5141\u8bb8\u65b9\u6cd5\u8bbf\u95ee\u548c\u4fee\u6539\u6570\u7ec4\u5185\u5bb9\u3002\u6b64\u5916\uff0c\u6d45\u62f7\u8d1d\u521b\u5efa\u5bf9\u540c\u4e00\u6570\u7ec4\u5bf9\u8c61\u7684\u5f15\u7528\uff0c\u800c\u6df1\u62f7\u8d1d\u521b\u5efa\u4e00\u4e2a\u65b0\u6570\u7ec4\u5e76\u590d\u5236\u539f\u59cb\u6570\u7ec4\u7684\u5185\u5bb9\u3002 Java \u6570\u7ec4\u5982\u4f55\u4f20\u9012\u5730\u5740 \u5728 Java \u4e2d\uff0c\u6570\u7ec4\u672c\u8d28\u4e0a\u662f\u5bf9\u8c61\uff0c\u4f46\u5b83\u4eec\u4e5f\u662f\u5f15\u7528\u7c7b\u578b\u3002\u8fd9\u610f\u5473\u7740\u5b83\u4eec\u5b58\u50a8\u5bf9\u5b9e\u9645\u6570\u7ec4\u5185\u5bb9\u7684\u5f15\u7528\uff0c\u800c\u4e0d\u662f\u5185\u5bb9\u672c\u8eab\u3002\u5f53\u6211\u4eec\u5c06\u4e00\u4e2a\u6570\u7ec4\u53c2\u6570\u4f20\u9012\u7ed9\u4e00\u4e2a\u65b9\u6cd5\u65f6\uff0c\u5b9e\u9645\u4e0a\u662f\u4f20\u9012\u4e86\u8be5\u6570\u7ec4\u7684\u5f15\u7528\u3002 \u4f20\u9012\u5f15\u7528 \u5f53\u6211\u4eec\u5c06\u4e00\u4e2a\u6570\u7ec4\u4f5c\u4e3a\u53c2\u6570\u4f20\u9012\u7ed9\u4e00\u4e2a\u65b9\u6cd5\u65f6\uff0c\u65b9\u6cd5\u4f1a\u6536\u5230\u8be5\u6570\u7ec4\u7684\u5f15\u7528\u3002\u8fd9\u610f\u5473\u7740\u8be5\u65b9\u6cd5\u53ef\u4ee5\u8bbf\u95ee\u5e76\u4fee\u6539\u6570\u7ec4\u7684\u5185\u5bb9\uff0c\u4f46\u4e0d\u80fd\u4fee\u6539\u6570\u7ec4\u672c\u8eab\u7684\u957f\u5ea6\u6216\u7c7b\u578b\u3002 \u7acb\u5373\u5b66\u4e60\u201c\u201d\uff1b public static void modifyArray(int[] arr) { arr[0] = 10; } public static void main(String[] args) { int[] arr = {1, 2, 3}; modifyArray(arr); System.out.println(Arrays.toString(arr)); \/\/ \u8f93\u51fa\uff1a[10, 2, 3] } \u767b\u5f55\u540e\u590d\u5236 \u6d45\u62f7\u8d1d\u548c\u6df1\u62f7\u8d1d \u6d45\u62f7\u8d1d\uff1a\u5f53\u6211\u4eec\u4f7f\u7528\u8d4b\u503c\u8fd0\u7b97\u7b26\uff08=\uff09\u5c06\u4e00\u4e2a\u6570\u7ec4\u5206\u914d\u7ed9\u53e6\u4e00\u4e2a\u53d8\u91cf\u65f6\uff0c\u6211\u4eec\u521b\u5efa\u4e86\u8be5\u6570\u7ec4\u7684\u6d45\u62f7\u8d1d\u3002\u6d45\u62f7\u8d1d\u5c06\u4e24\u4e2a\u53d8\u91cf\u6307\u5411\u540c\u4e00\u6570\u7ec4\u5bf9\u8c61\u3002\u5bf9\u5176\u4e2d\u4e00\u4e2a\u6570\u7ec4\u6240\u505a\u7684\u4efb\u4f55\u66f4\u6539\u90fd\u4f1a\u5f71\u54cd\u53e6\u4e00\u4e2a\u6570\u7ec4\u3002 int[] arr1 = {1, 2, 3}; int[] arr2 = arr1; \/\/ \u6d45\u62f7\u8d1d [&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-65299","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/65299","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=65299"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/65299\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=65299"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=65299"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=65299"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}