LeetCode371. Sum of Two Integers 两个整数相加,不使用+ -法

先贴上代码,代码是别人的,为了帮助理解,这里给出解释,如果有什么错误希望纠正和海涵。

class Solution {
    public int getSum(int a, int b) {
        if(b == 0)return a;
        int carry = (a & b) << 1;
        int sum = a ^ b;
        return getSum(sum , carry);
    }
}

LeetCode371. Sum of Two Integers 两个整数相加,不使用+ -法