// XOR swap fail for swapping array elements if two indexes refer to the same element.
{
   int[] x = { 100, 200};
   int i = 0, j = 1;
   x[i] ^= x[j];
   x[j] ^= x[i];
   x[i] ^= x[j];
   // prints 200 100
   out.println( x[0] + " " + x[1] );
}
{
   int[] x = { 100, 200};
   int i = 0, j = 0;
   x[i] ^= x[j];
   x[j] ^= x[i];
   x[i] ^= x[j];
   // prints 0 200
   out.println( x[0] + " " + x[1] );
}