程序如下:
public class Test{
public void changeValue(int[] b){
b[2] = 4;
System.out.print("changeValue:");
for(int i = 0; i<b.length;i++)
{
System.out.print(" "+b[i]);
}
}
public static void main(String[] args) {
Test test = new Test();
int[] a={1,2,3};
test.changeValue(a);
System.out.print("\nmain:");
for(int i = 0; i<a.length;i++)
{
System.out.print(" "+a[i]);
}
}
}
输出:
changeValue: 1 2 4
main: 1 2 4
为啥?java中又没有指针,怎么就实现了传地址操作 |