public class IMP {
public static void main(String args[])
{
Test obj = new Test();
System.out.println("outside has code before :"+obj.hashCode());
amethod(obj);
System.out.println("outside has code after :"+obj.hashCode());
System.out.println(obj.meat);//NOTE
}
static void amethod(Test xobj)
{xobj.meat = "chicken";
System.out.println("Inside has code :"+xobj.hashCode());
xobj = null;
}
}
class Test {
String meat = "beef";
}
This gives output :
outside has code before :7434986
Inside has code :7434986
outside has code after :7434986
chicken So copy of refeence is send and restored after function call is returned.