hi all ranchers,
just have a look at the code
though it has been discussed before i could not get it..
the output is 10,0,20
but i feel it should be 10,0,10
as once refernce is being lost how it can have the old value
pl. guide
thanks in advance
class ValHold{
public int i = 10;
}
public class ObParm{
public static void main(String argv[]){
ObParm o = new ObParm();
o.amethod();
}
public void amethod(){
int i=99;
ValHold v = new ValHold();
v.i=30;
//System.out.println("Before another = "+ v.i);
another(v,i);
System.out.println("After another = "+ v.i);
}//End of amethod
public void another(ValHold v,int i){
i=0;
v.i = 20;
ValHold vh=new ValHold();
System.out.println("vh.i ="+vh.i);
v=vh;
System.out.println(v.i+" "+i);
}//End of another
}
regards
srijan