Here is a simple program to swap to numbers with Exclusive OR
Output :
5
4
public class Swap {
public static void main(String args[])
{
int a=4;
int b=5;
a^=b;
b^=a;
a^=b;
System.out.println(a);
System.out.println(b);
}
}
Output :
5
4
No comments:
Post a Comment