View Single Post
Old 05-05-2004, 08:15 AM   #2 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,486
sde is on a distinguished road
ok, am i correct in assuming the reference will hold until i assign the object to a new object inside the method?

here's the best example i found:
Code:
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;
                another(v,i);
                System.out.print( v.i );
        }//End of amethod

        public void another(ValHold v, int i){
                i=0;
                v.i = 20;
                ValHold vh = new ValHold();
                v =  vh;
                System.out.print(v.i);
        System.out.print(i);
        }//End of another

}
__________________
Mike
sde is offline   Reply With Quote