引用传递
示例:
public class Test3 { public static void change(int []a){ a[0]=50; } public static void main(String[] args) { int []a={10,20}; System.out.println(a[0]); change(a); System.out.println(a[0]); } }
值传递
示例:
public class Test3 { public static void change(int a){ a=50; } public static void main(String[] args) { int a=10; System.out.println(a); change(a); System.out.println(a); } }
时间: 2024-10-21 13:48:43