程序输出题20200801
class Two{
Byte x;
}
class PassO{
public static void main(String[] args){
PassO p=new PassO();
p.start();
}
void start(){
Two t=new Two();
System.out.print(t.x+””);
Two t2=fix(t);
System.out.print(t.x+” ” +t2.x);
}
Two fix(Two tt){
tt.x=42;
return tt;
}
}
1.Byte x Byte是包装类,默认值是null
2.t是一个引用地址,在调用fix(TWO tt)函数时,是一个实参到形参的传值,也就是把t的地址赋值给了tt,但是都指向堆内存中新建的对象,因此,tt.x 和 t.x指向是相同的,都是42
3.Two t2=fix(t); fit函数返回的还是一个引用地址,这句代码相当于把tt的地址赋值给了t2

浙公网安备 33010602011771号