public class SwapNoTemp
{
public static void main(String[] args)
{
try
{
int a=Integer.parseInt(args[0]);
int b=Integer.parseInt(args[1]);
System.out.println("Values before swapping\n");
System.out.println("a="+a+" b="+b);
a=a+b;
b=a-b;
a=a-b;
System.out.println("Values after swapping\n");
System.out.println("a="+a+" b="+b);
}
catch(Exception e)
{
System.out.println("Error! Please see the below stack trace\n\n");
e.printStackTrace();
}
}
}
{
public static void main(String[] args)
{
try
{
int a=Integer.parseInt(args[0]);
int b=Integer.parseInt(args[1]);
System.out.println("Values before swapping\n");
System.out.println("a="+a+" b="+b);
a=a+b;
b=a-b;
a=a-b;
System.out.println("Values after swapping\n");
System.out.println("a="+a+" b="+b);
}
catch(Exception e)
{
System.out.println("Error! Please see the below stack trace\n\n");
e.printStackTrace();
}
}
}
No comments:
Post a Comment