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

public class Swapping

{

                public static void main(String arg[])

                {

                                int a=7,b=9;

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

                                System.out.println(a);

                                System.out.println(b);

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

                                a=(a+b)-(b=a);

                                System.out.println(a);

                                System.out.println(b);

                }

}

, , , , ,

Leave a Reply