Swapping Program in Java
public class JavaSwap
{
public static void main(String[] args)
{
int a=10, b=20, temp;
System.out.println("Before swapping");
System.out.println("value of a="+a);
System.out.println("value of b="+b);
temp=a;
a=b;
b=temp;
System.out.println("After swapping");
System.out.println("value of a="+a);
System.out.println("value of b="+b);
}
}
Output:
Before swapping value of a=10 value of b=20 After swapping value of a=20 value of b=10b. tech. bca icse java java tutorials learn java mca programs