Skip to content

Instantly share code, notes, and snippets.

@dmnugent80
Created February 1, 2015 23:59
Show Gist options
  • Save dmnugent80/f0df583751a0018cdacf to your computer and use it in GitHub Desktop.
Save dmnugent80/f0df583751a0018cdacf to your computer and use it in GitHub Desktop.
Binary XOR Swap int values
int x=10;
int y=25;
System.out.println("x= " + x + " y = " + y);
x ^= (y ^= x);
y ^= x;
System.out.println("x= " + x + " y = " + y);
/*output
x= 10 y = 25
x= 25 y = 10
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment