新手第一次发帖,刚刚看到的练习题,改了一下,不知这样理解对不?
class Test{
public int i=10;
}
public class ObParm{
public static void main(String argv[]){
int i = 100;
Test v = new Test();
Test vh=new Test();
ObParm o=new ObParm();
o.amethod();
System.out.println(v.i+" "+i);
System.out.println(vh.i);
}
public void amethod(){
int i=99;
Test v=new Test();
v.i=30;
Test vh=new Test();
vh.i=50;
another(vh,i);
System.out.println(v.i+" "+i);
System.out.println(vh.i);
}
public void another(Test v, int i){
i=0;
v.i=20;
Test vh=new Test();
v=vh;
System.out.println(v.i+" "+i);
}
}
大家说说结果会是多少?