import static java.lang.System.out;
class Swap
{
static public void main(String args[])
{
int a=10,b=20;
out.println("Before Swap a = "+a+" b = "+b);
a=a+b;
b=a-b;
a=a-b;
out.println("After Swap a = "+a+" b = "+b);
}
}
class Swap
{
static public void main(String args[])
{
int a=10,b=20;
out.println("Before Swap a = "+a+" b = "+b);
a=a+b;
b=a-b;
a=a-b;
out.println("After Swap a = "+a+" b = "+b);
}
}
0 Comment to "Java program to swap two numbers without using temporary variable."
Post a Comment