How to Swap Two Number without using any Third Variable and Arithmetic Operator

Step 1: let us open the notepad and write the following code.
Code:
  1. class swap {
  2. public static void main(String arg[]) {
  3. System.out.println("Before swapping");
  4. int a = 20;
  5. int b = 40;
  6. System.out.println("value of a:" + a);
  7. System.out.println("value of b:" + b);
  8. System.out.println("After swapping");
  9. a = a ^ b;
  10. b = a ^ b;
  11. a = a ^ b;
  12. System.out.println("value of a:" + a);
  13. System.out.println("value of b:" + b);
  14. }
  15. }
Step 2: Name it as "sp.java" and save the file in any location. I saved at "C:/kiran/program".
Step 3: Open command prompt(press window +R and write cmd and hit ok).
a
Step 4: Open command prompt.
s
Step 5: Go to "C:/kiran/program" by using cmd.
d
Step 6: now, write the following code for checking my java file is compile or not.
javac sp.java
my java file is compiled successfully.
Step 7: Write the following code in command prompt. Press enter and see the output.
java demo
//demo is a class name that is written in my "hasrel.java" file.
output
f
Happy codding.