class Swap { public static void main(String…s) { int a,b,temp; a=Integer.parseInt(s[0]); b=Integer.parseInt(s[1]); System.out.println(“nBefore Swap:n”+”a=”+a+”tb=”+b); temp=a; a=b; b=temp; System.out.println(“n After Swap:n”+”a=”+a+”t b=”+b); } }
5 6 Before Swap: a=5 b=6 After Swap : a=6 b= 5
Here we interchange the value of both the variable using third variable.