ann.gui.Stack

 

Stack.java presents a Stack class whose integrity cannot be violated(unlike Java's Stack class). It is built using Java's standard LinkedList class.

 

public Stack()

Stack constructor

Postcondition: Empty stack is constructed.

 

public boolean isEmpty()

Check if stack is empty

Return: true if stack is empty, and false otherwise

 

public Object top()

Top operation

Return: Object at the top of the stack; null if stack is empty

 

public void push(Object value)

Push operation

Receive: Object value

Postcondition: value has been added at the top of the stack

 

public Object pop()

Pop operation

Return: Object at the top of the stack; null if stack is empty

Postcondition: Value at the top of the stack has been removed.

 


Back to the package documentation index


Back to the Introduction


Copyright 2000 by Prentice Hall. All rights reserved.