The output of the fist System.out.println()
is not same as the second System.out.println()
What may be the reason?
public class swapex{
public static int var1, var2;
public void badSwap(int var1, int var2){
int temp = var1;
this.var1 = var2;
this.var2 = temp;
System.out.println("var1 " + var1 + " var2 "+ var2);
}
public static void main(String args[])
{
swapex sw= new swapex();
sw.badSwap(10,20);
System.out.println("var1 " + var1 + " var2 "+ var2);
}
}