Java program to swap two numbers

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(“nAfter Swap:n”+”a=”+a+”tb=”+b);
}
}

Output

Java program to swap two numbers

Leave a Comment

error: Alert: Content is protected!!