我的代码是:
public class MyProgram {
public void start() {
int a = 1;
int[] b = { 1, 2, 3};
int[] c = { 1, 2, 3};
method1(a, b[0], c);
System.out.println("a = " + a);
System.out.println("b[0] = " + b[0]);
System.out.println("c[0] = " + c[0]);
}
private void method1(int x, int y, int[] z) {
x++;
y = 10;
if ( z.length >= 1 ) {
z[0] = 100;
}
System.out.println(x);
System.out.println(y);
}
}
输出是
a = 1
b[0] = 1
c[0] = 100
我真的不知道为什么只有 c[0] 发生了变化。