Swap two variables without using arithmetic operator & third variable

public class Test {

        public static void main(String[] args) {

                int a = 11;
                int b = 21;
                System.out.format("Before swapping : a = %d,b=%d \n", a, b);
                swap(a, b);

        }

        public static void swap(int a, int b) {
                b = a ^ b;

                a = a ^ b;

                b = a ^ b;

                System.out.format("After swapping : a = %d,b=%d", a, b);
        }
}

Interview Questions: 

Search