Write a program in java to swap two number without third variable?

public class Swap

{

                public static void main(String arg[])

                {

                                int a=6,b=7;

                                System.out.println("Before Swapping");

                                System.out.println(a);

                                System.out.println(b);

                                System.out.println("After Swapping");

                                a=a+b;

                                b=a-b;

                                a=a-b;

                                System.out.println(a);

                                System.out.println(b);

                }

}

, , , ,

Leave a Reply