class objTest
{
int i,j;
public static void main(
String args[])
{
objTest h1= new objTest();
h1.i=2;
h1.j=3;
System.out.println(" before swaping value are "+ h1.i+" "+h1.j);
h1.swap(h1);
System.out.println(" afer swaping value are "+ h1.i+" "+h1.j);
}
void swap(objTest obj)
{
int temp;
temp=obj.i;
obj.i=obj.j;
obj.j=temp;
System.out.println("Befor null Swap Function value are "+ obj.i+" "+obj.j);
obj=null;
}
}
Above program will swap the i & j intergers through the obj object.
Above swap method i am making obj as null then also final values are getting me as swapped values only .
May i know the reason behind this program?
Thanks,
Sigamala