question: public int evalRPN ( String [ ] tokens ) { if ( tokens == null || tokens . length == 0 ) return 0 ; Stack < String > s = new Stack < String > ( ) ; int len = tokens . length ; for ( int i = 0 ; i < len ; i ++ ) { String cur = tokens [ i ] ; if ( isOperator ( cur ) ) { int t2 = Integer . parseInt ( s . pop ( ) ) ; int t1 = Integer . parseInt ( s . pop ( ) ) ; int res = calculate ( t1 , t2 , cur ) ; s . push ( Integer . toString ( res ) ) ; } else s . push ( cur ) ; } return Integer . valueOf ( s . peek ( ) ) ; }
target:  assign a priority for each operators use a stack to store them note the numbers can be negative We evaluate the expression left-to-right and push operands onto the stack until we encounter an operator, which we pop the top two values from the stack. We then evaluate the operator, with the values as arguments and push the result back onto the stack.