{"id":37937,"date":"2024-11-26T08:56:40","date_gmt":"2024-11-26T00:56:40","guid":{"rendered":"https:\/\/fwq.ai\/blog\/37937\/"},"modified":"2024-11-26T08:56:40","modified_gmt":"2024-11-26T00:56:40","slug":"java%e6%80%8e%e4%b9%88%e5%b0%86%e6%95%b0%e7%bb%84%e4%bc%a0%e5%88%b0%e5%87%bd%e6%95%b0%e4%b8%ad","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/37937\/","title":{"rendered":"java\u600e\u4e48\u5c06\u6570\u7ec4\u4f20\u5230\u51fd\u6570\u4e2d"},"content":{"rendered":"<blockquote><p>\n  \u5728 java \u4e2d\u5c06\u6570\u7ec4\u4f20\u7ed9\u51fd\u6570\u6709\u4e24\u79cd\u65b9\u5f0f\uff1a\u901a\u8fc7\u4f20\u9012\u5f15\u7528\u6216\u4f20\u9012\u62f7\u8d1d\u3002\u4f20\u9012\u5f15\u7528\u5141\u8bb8\u51fd\u6570\u4fee\u6539\u539f\u59cb\u6570\u7ec4\uff0c\u800c\u4f20\u9012\u62f7\u8d1d\u5219\u4f1a\u521b\u5efa\u539f\u59cb\u6570\u7ec4\u7684\u526f\u672c\uff0c\u51fd\u6570\u65e0\u6cd5\u4fee\u6539\u6b64\u526f\u672c\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202411\/13\/2024111313275775014.jpg\" class=\"aligncenter\" title=\"java\u600e\u4e48\u5c06\u6570\u7ec4\u4f20\u5230\u51fd\u6570\u4e2d\u63d2\u56fe\" alt=\"java\u600e\u4e48\u5c06\u6570\u7ec4\u4f20\u5230\u51fd\u6570\u4e2d\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5728 Java \u4e2d\u5c06\u6570\u7ec4\u4f20\u5230\u51fd\u6570<\/strong><\/p>\n<p>\u5728 Java \u4e2d\uff0c\u53ef\u4ee5\u901a\u8fc7\u4e24\u79cd\u65b9\u5f0f\u5c06\u6570\u7ec4\u4f20\u9012\u7ed9\u51fd\u6570\uff1a<\/p>\n<p><strong>1. \u4f20\u9012\u5f15\u7528<\/strong><\/p>\n<p>\u5c06\u6570\u7ec4\u7684\u5f15\u7528\uff08\u5373\u6570\u7ec4\u7684\u5730\u5740\uff09\u4f20\u9012\u7ed9\u51fd\u6570\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u51fd\u6570\u53ef\u4ee5\u4fee\u6539\u6570\u7ec4\u4e2d\u7684\u5143\u7d20\uff0c\u5e76\u4e14\u8fd9\u4e9b\u4fee\u6539\u5c06\u5728\u51fd\u6570\u8c03\u7528\u8005\u53ef\u89c1\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(arr[0]); \/\/ \u8f93\u51fa\uff1a10\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>2. \u4f20\u9012\u62f7\u8d1d<\/strong><\/p>\n<p>\u5c06\u6570\u7ec4\u7684\u62f7\u8d1d\u4f20\u9012\u7ed9\u51fd\u6570\u3002\u51fd\u6570\u65e0\u6cd5\u4fee\u6539\u62f7\u8d1d\u4e2d\u7684\u5143\u7d20\uff0c\u5bf9\u62f7\u8d1d\u7684\u4efb\u4f55\u4fee\u6539\u90fd\u4e0d\u4f1a\u53cd\u6620\u5728\u51fd\u6570\u8c03\u7528\u8005\u4e2d\u3002<\/p>\n<pre>public static void printArrayCopy(int[] arr) {\n    for (int i = 0; i &lt; arr.length; i++) {\n        System.out.print(arr[i] + \" \");\n    }\n    System.out.println();\n}\n\npublic static void main(String[] args) {\n    int[] arr = {1, 2, 3};\n    printArrayCopy(arr); \/\/ \u8f93\u51fa\uff1a1 2 3\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fjava\u600e\u4e48\u5c06\u6570\u7ec4\u4f20\u5230\u51fd\u6570\u4e2d\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\u5c06\u6570\u7ec4\u4f20\u7ed9\u51fd\u6570\u6709\u4e24\u79cd\u65b9\u5f0f\uff1a\u901a\u8fc7\u4f20\u9012\u5f15\u7528\u6216\u4f20\u9012\u62f7\u8d1d\u3002\u4f20\u9012\u5f15\u7528\u5141\u8bb8\u51fd\u6570\u4fee\u6539\u539f\u59cb\u6570\u7ec4\uff0c\u800c\u4f20\u9012\u62f7\u8d1d\u5219\u4f1a\u521b\u5efa\u539f\u59cb\u6570\u7ec4\u7684\u526f\u672c\uff0c\u51fd\u6570\u65e0\u6cd5\u4fee\u6539\u6b64\u526f\u672c\u3002 \u5728 Java \u4e2d\u5c06\u6570\u7ec4\u4f20\u5230\u51fd\u6570 \u5728 Java \u4e2d\uff0c\u53ef\u4ee5\u901a\u8fc7\u4e24\u79cd\u65b9\u5f0f\u5c06\u6570\u7ec4\u4f20\u9012\u7ed9\u51fd\u6570\uff1a 1. \u4f20\u9012\u5f15\u7528 \u5c06\u6570\u7ec4\u7684\u5f15\u7528\uff08\u5373\u6570\u7ec4\u7684\u5730\u5740\uff09\u4f20\u9012\u7ed9\u51fd\u6570\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u51fd\u6570\u53ef\u4ee5\u4fee\u6539\u6570\u7ec4\u4e2d\u7684\u5143\u7d20\uff0c\u5e76\u4e14\u8fd9\u4e9b\u4fee\u6539\u5c06\u5728\u51fd\u6570\u8c03\u7528\u8005\u53ef\u89c1\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(arr[0]); \/\/ \u8f93\u51fa\uff1a10 } \u767b\u5f55\u540e\u590d\u5236 2. \u4f20\u9012\u62f7\u8d1d \u5c06\u6570\u7ec4\u7684\u62f7\u8d1d\u4f20\u9012\u7ed9\u51fd\u6570\u3002\u51fd\u6570\u65e0\u6cd5\u4fee\u6539\u62f7\u8d1d\u4e2d\u7684\u5143\u7d20\uff0c\u5bf9\u62f7\u8d1d\u7684\u4efb\u4f55\u4fee\u6539\u90fd\u4e0d\u4f1a\u53cd\u6620\u5728\u51fd\u6570\u8c03\u7528\u8005\u4e2d\u3002 public static void printArrayCopy(int[] arr) { for (int i = 0; [&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-37937","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/37937","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=37937"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/37937\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=37937"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=37937"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=37937"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}