Social Icons

Tuesday, 11 February 2014

Java program to swap two numbers using command line

class Swap
{
public static void main(String args[])
{
int a,b,temp;
a=Integer.parseInt(args[0]);
b=Integer.parseInt(args[1]);

System.out.println("\n Before Swap:\n"+" a="+a+"\tb="+b);

temp=a;
a=b;
b=temp;

System.out.println("\n After Swap:\n"+" a="+a+"\tb="+b);
}
}


                                                     Output



No comments:

Post a Comment