public int evalRPN(String[] tokens) {
        int result = 0;
        if (tokens.length == 0) {
            return result;
        }

        //get all operatores
        String operators = "+-*/";
        //build a stack to store the records
        Stack<String> stack = new Stack<>();

        //go through all the tokens
        for (String s : tokens) {
            // if s is not an valid operator, then s is a num, push in stack
            if (!operators.contains(s)) {
                stack.push(s);
            } // if s is an valid operator, pop two nums, calculate, push back
            else {
                int a = Integer.valueOf(stack.pop());
                int b = Integer.valueOf(stack.pop());

                // caculate based on the rule, as put into the stack first, the number a and b need to reverse as normal
                switch (s) {
                    case "+":
                        stack.push(String.valueOf(b + a));
                        break;
                    case "-":
                        stack.push(String.valueOf(b - a));
                        break;
                    case "*":
                        stack.push(String.valueOf(b * a));
                        break;
                    case "/":
                        stack.push(String.valueOf(b / a));
                        break;
                }
            }
        }

        //if validate, after loop, pop the last num as result
        result = Integer.valueOf(stack.pop());

        return result;
    }