This EmptyStackException continues to pop up. Obliviously there is nothing in my stack, but the first element that the User inputs. However, I am not sure where the code i
A stack is LIFO, or "Last in, First out". So when you have an input sequence of 4 5 * 6 -
and do this:
rpnStack.push(st.nextToken());
The first thing you pop will be "-", the second thing will be "6", and the third thing will be "*". Is this what you expect?
Also, instead of:
String temp1 = stack.peek();
stack.pop();
You can do:
String temp1 = stack.pop();