20155223 第十一周课堂编码

20155223 第十一周课堂编码

内容一

内容二

根据以下功能描述补全代码:
图中橙色方框内为需补充部分。

补全后的代码片段:

while (tokenizer.hasMoreTokens()) {
            token = tokenizer.nextToken();


            if (isOperator(token)) {
                op2 = (stack.pop()).intValue();
                op1 = (stack.pop()).intValue();
                result = evalSingleOp(token.charAt(0), op1, op2);
                stack.push(new Integer(result));
            } else {
                stack.push(new Integer(Integer.parseInt(token)));
            }

        }

补全代码后的运行截图:

原文地址:https://www.cnblogs.com/battlefieldheros/p/6802468.html