Simple explanation on how to arrive at the solution 
There\'s lot of answers here, but none of them shows how they arrived at the answer, here\'s my simple try to explain. \n\nEg: Let\'s try this with our hand  3 
There\'s lot of answers here, but none of them shows how they arrived at the answer, here\'s my simple try to explain. \n\nEg: Let\'s try this with our hand  3 + 2 = 5 , the carry will be with in the brackets i.e "()" \n```\n3 => 011 \n2=>  010\n     ____\n     1(1)01\n```\n\nHere we will forward the carry  at the second bit to get the result.\nSo which bitwise operator can do this ? A simple observation says that XOR can do that,but it just falls short in dealing with the carry properly, but correctly adds when there is no need to deal with carry.\nFor Eg: \n```\n1   =>  001 \n2   =>  010 \n1^2 =>  011 (2+1 = 3) \n```\n\nSo now when we have carry, to deal with, we can see the result as : \n```\n3  => 011 \n2  => 010 \n3^2=> 001  \n```\nHere we can see  XOR just fell  short with the carry  generated at the second bit. \nSo how can we find the carry ? The carry is generated when both the bits are set, i.e (1,1) will generate carry but (0,1 or 1,0 or 0,0) won\'t generate a carry, so which bitwise operator can do that ?  AND gate ofcourse. \n\nTo find the carry we can do \n```\n3    =>  011 \n2    =>  010 \n3&2  =>  010\n```\nnow we need to add it to the previous value we generated i.e ( 3 ^ 2), but the carry should be added to the left bit of the one which genereated it. \nso we left shift it by one so that it gets added at the right spot. \n\nHence  (3&2)<<1  => 100 \nso we can now do \n```\n3 ^2        =>  001 \n(3&2)<<1    =>  100 \n\nNow xor them, which will give 101(5) , we can continue this until the carry becomes zero.\n\n```\nA Java program which implements the above logic :\n\n```\nclass Solution {\n    public int getSum(int a, int b) {\n      int c; \n      while(b !=0 ) {\n        c = (a&b);\n        a = a ^ b;\n        b = (c)<<1;\n      }\n      return a;\n        \n    }\n}\n```\nHope I made some sense, If not I am really sorry for wasting your time.
[]