import java.util.Arrays;
public class Test {
public static void main(String[] args) {
int i=1;
String str ="hello";
Integer num=2;
int [] arr={1,2,3,4,5};
MyData my =new MyData();
chang(i,str,num,arr,my);
System.out.println("i="+i);
System.out.println("str="+str);
System.out.println("num="+num);
System.out.println("arr="+ Arrays.toString(arr));
System.out.println("my.a="+my.a);
}
public static void chang(int j,String s,Integer n,int[] a,MyData m){
j+=1;
s+="world";
n+=1;
a[0] +=1;
m.a+=1;
}
}
class MyData{
int a=10;
}
i=1
str=hello
num=2
arr=[2, 2, 3, 4, 5]
my.a=11
形参列表:
int j,String s,Integer n,int[] a,MyData m
实参列表:
chang(i,str,num,arr,my);
形参是基本数据类型:传递的是数据值
形参是引用数据类型:传递的是地址值