Evaluate Reverse Polish Notation LeetCode solution in Java
1class Solution {2public int evalRPN(String[] tokens) {3Stack<Integer> stack = new Stack();4for (String i : tokens) {5if (i.equals("+") || i.equals("-") || i.equals("*") || i.equals("/")) {6int a = stack.pop();7int b = stack.pop();8int temp = 0;9if (i.equals("+")) temp = a + b;10else if (i.equals("-")) temp = b - a;11else if (i.equals("*")) temp = a * b;12else if (i.equals("/")) temp = b / a;13stack.push(temp);14} else stack.push(Integer.parseInt(i));15}16return stack.pop();17}18}