Hi all,
We say that in
Java language we pass by value only, look into the snippet below:
public class PassByRef
{
int i=1;
int j=2;
public void change(PassByRef obj)
{
obj.i=obj.i*10;
obj.j=obj.j*10;
}
public static void main(
String a[])
{
PassByRef obj1= new PassByRef();
obj1.change(obj1);
System.out.println("*****obj1.i is **"+obj1.i);
System.out.println("*****obj1.j is **"+obj1.j);
}
}
Here we are passing the reference of the object as arguments to the method when method is called.
Thanks & Regards,
amit