Say x & y are the integer variables. The challenge is to swap them without using a temporary variable.
The solution is as simple as the problem itself:
x = x + y;
y = x - y;
x = x - y;
Update 1: Jack and Alexey pointed out a typo in my solution which has since been corrected. Please see their comments below.
The simplicity of the solution appeals to me. It clearly demonstrates the meaning of assignment operator ( "=" ).
What if they are Strings?
Note: You can use String methods in Java API.