Created
February 1, 2015 23:59
-
-
Save dmnugent80/f0df583751a0018cdacf to your computer and use it in GitHub Desktop.
Binary XOR Swap int values
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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