java/Basics/SumWithoutUsingPlusOperator.java
<gh_stars>0import java.util.*;

public class SumWithoutUsingPlusOperator {
    public static void main(String[] args) {
        System.out.print(getSum(2,3));
    }

    public static int getSum(int a, int b) {
        if(a==0) return b;
        if(b==0) return a;
        while(b!=0) {
            int carry = a&b;
            a=a^b;
            b=carry<<1;
        }
        return a;
    }
}