Problems with stack in an infix to postfix converter
问题 Good day! I am implementing an infix to postfix converter using stacks. It works when the user input an infix expression with no parenthesis; but when a parenthesis is present, the console says: Exception in thread "main" StackEmptyException: Stack is empty. at ArrayStack.top(ArrayStack.java:85) at InfixToPostfix.convert(InfixToPostfix.java:54) at InfixToPostfix.main(InfixToPostfix.java:85) My problem is in implementing the rank (top of the stack). 回答1: Aha! You need "stack peek" when