BUG LAB · Stack
Subtract in the right order
Which postfix expression exposes the reversed operands?
Java · intentionally broken snippet
int a = stack.pop();
int b = stack.pop();
if (operator.equals("-")) stack.push(a - b);Assume ordinary supporting code and valid inputs unless the question states otherwise.
Choose an answer before revealing the trace. Keys 1 to 3 work too.