You all are aware of the word swapping. It is the interchanging of values. Here we are going to swap the two variables without using third variable.
class Swapping { public static void main(String[] args) { int num1 = 10; int num2 = 20; num1 = num1 + num2; num2 = num1 - num2; num1 = num1 - num2; System.out.println("After swapping, num1= " + num1 + " and num2= "+ num2); } }