Java program to swap two numbers using bitwise xor operator

Java program to swap two numbers using bitwise xor operator. The source code for a Java program that uses the Bitwise XOR operation to swap the contents of two numbers. As input, choose any two integer numbers. Then we discover the bitwise XOR of the first and second variables and store the result in the first variable. We repeat the bitwise XOR operation on the same variables and save the result in the second variable.

import java.util.Scanner;
public class Main
{
public static void main(String args[])
{
int m, n;
Scanner s = new Scanner(System.in);
System.out.print("Enter the first number");
m = s.nextInt();
System.out.print("Enter the second number");
n = s.nextInt();
m = m ^ n;
n = m ^ n;
m = m ^ n;
System.out.println("After Swapping the number");
System.out.println("First number:"+m);
System.out.println("Second number:"+n);
}
}

Enter the first number 45
Enter the second number 56
After Swapping the number
First number: 56
Second number: 45