Java program to swap two numbers

1 Swapping two numbers using third variable

Output

2. Swapping two numbers without using third variable

Output

3. Swapping two numbers in a single line using addition and subtraction

Output

4. Swapping two numbers in a single line using multiplication and division

Output

5. Swapping two numbers using multiplication and division

Here numbers must be non zero

Output

6. Swapping two numbers using XOR operator

above operation can also be written as

Output

Output