我想在java中编写一个评估表达式的代码,比如括号和括号等是否闭合,但我必须使用堆栈来完成。我已经做了 Stack 接口、StackEmptyException 类和 StackFullException 类。
public interface Stack
{
public int size( );
// Returns the size of the Stack
public boolean isEmpty( );
// Returns true if the Stack is empty
public boolean isFull( );
// Returns true if the Stack is full
public Object top( ) throws StackEmptyException;
// Returns the top item of the Stack
public void push(Object item) throws StackFullException;
// Adds a new item into the Stack
public Object pop( ) throws StackEmptyException;
// Removes the top item of the Stack
}//End of interface Stack