Standard Swap problem

public class SwapVariables
{
public static void main(String args[])
{
int a=5;
int b= 6;

System.out.println(“Before Swap :”+a+” “+b);

a=a+b;
b=a-b;
a=a-b;

System.out.println(“After Swap :”+a+” “+b);

}
}

Published by Chaitanya

I am a family man, perpetual learner, coffee drinker, dessert eater and Happiness Engineer at Automattic. I also read, write, move, and meditate.

Leave a comment

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: