@@ -0,0 +1,2476 @@
+import java.util.Stack;%0A%0Apublic class LeetCode0224 %7B%0A%0A    private Stack%3CCharacter%3E signStack = new Stack%3CCharacter%3E();%0A    private Stack%3CInteger%3E numStack = new Stack%3CInteger%3E();%0A%0A    public int calculate(String s) %7B%0A        if (s == null %7C%7C s.length() == 0) %7B%0A            return 0;%0A        %7D%0A%0A        signStack.push('+'); //extra add '0+'%0A        numStack.push(0);%0A%0A        for (int i = 0; i %3C s.length(); i++) %7B%0A            char c = s.charAt(i);%0A            if (c == ' ') %7B%0A                continue;%0A            %7D%0A            if (Character.isDigit(c)) %7B%0A                int num = c - '0';%0A                for (++i; i %3C s.length(); i++) %7B%0A                    if (Character.isDigit(s.charAt(i))) %7B%0A                        num = num * 10 + s.charAt(i) - '0';%0A                    %7D else if (c == ' ') %7B%0A                        continue;%0A                    %7D else %7B%0A                        break;%0A                    %7D%0A                %7D%0A                i--;%0A%0A                if (signStack.peek() == '*') %7B%0A                    numStack.push(numStack.pop() * num);%0A                %7D else if (signStack.peek() == '/') %7B%0A                    if (num == 0) %7B%0A                        return 0;%0A                    %7D%0A                    numStack.push(numStack.pop() / num);%0A                %7D else %7B%0A                    numStack.push(num);%0A                %7D%0A            %7D else if (c == '(') %7B%0A                signStack.push('(');%0A                numStack.push(0); //extra add '0+'%0A                signStack.push('+');%0A            %7D else if (c == ')') %7B%0A                while (signStack.peek() != '(') %7B%0A                    plusOrMinus();%0A                %7D%0A                signStack.pop();%0A            %7D%0A            if (c == '+' %7C%7C c == '-') %7B%0A                plusOrMinus();%0A                signStack.push(c);%0A            %7D%0A            if (c == '*' %7C%7C c == '/') %7B%0A                signStack.push(c);%0A            %7D%0A        %7D%0A%0A        while (!signStack.isEmpty()) %7B%0A            plusOrMinus();%0A        %7D%0A        return numStack.pop();%0A    %7D%0A%0A    private void plusOrMinus() %7B%0A        int o1 = numStack.pop();%0A        int o2 = numStack.pop();%0A%0A        boolean plus = signStack.pop() == '+' ? true : false;%0A%0A        if (plus) %7B%0A            numStack.push(o2 + o1);%0A        %7D else %7B%0A            numStack.push(o2 - o1);%0A        %7D%0A    %7D%0A%0A    public static void main(String%5B%5D args) %7B%0A        LeetCode0224 leetcode = new LeetCode0224();%0A        System.out.println(leetcode.calculate(%222-1+2%22));%0A    %7D%0A%7D

Add LeetCode0224.java