static int evalRPN(String[] tokens) {
        if (tokens.length == 0) return 0;
        Stack<String> stack = new Stack<>();
        for (String token : tokens) {
            if (token.length() == 1 && !Character.isDigit(token.charAt(0))) {
                int f = Integer.parseInt(stack.pop());
                int s = Integer.parseInt(stack.pop());
                if (token.equals("+")) stack.push(String.valueOf(f + s));
                else if (token.equals("/")) stack.push(String.valueOf(s / f));
                else if (token.equals("*")) stack.push(String.valueOf(s * f));
                else stack.push(String.valueOf(s - f));
            } else stack.push(token);
        }

        return Integer.parseInt(stack.pop());
    }
To solve this problem, I used stack. if the array element is operator, two elements from stack is popped
and do operation according to operator and push back to stack. In this way we calculate the whole expression
The last stack element is result of expression
src/problems/medium/EvaluateReversePolishNotation.java