class Swap { public static void main(String…s) { int a,b; a=Integer.parseInt(s[0]); b=Integer.parseInt(s[1]); System.out.println(“nBefore Swap:n”+”a=”+a+”tb=”+b); a=a+b; b=a-b; a=a-b; System.out.println(“nAfter Swap:n”+”a=”+a+”tb=”+b); } }
5 6 Before Swap: a=5 b=6 After Swap:a=6 b=5
In this Program, we have interchanged the value of variable without using third variable