This is one of the tricky question often asked in interviews.
The result for the below will be
int a =5, b =8;
temp = a;
a = b;
b = temp;
System.out.println("a = " + a + " b = " + b) // give result a=8 b =5
The above code swapped the variable values , Now the question is how can we achieve this without using the temp.
int double =5,double = 8;
a = a + b;
b = a -b;
a = (a - b) /2 ;
System.out.println("a = " + a + " b = " + b) // give result a=8 b =5
I like somebody to explain the below code.