Class Stack

java.lang.Object
  |
  +--Stack

public class Stack
extends java.lang.Object


Constructor Summary
Stack()
          Constructs a new stack object, initializing the stack to be empty
 
Method Summary
 boolean isEmpty()
          Tells whether or not the stack is empty
 Object peek()
          Returns the top element on the stack to the calling application, but does not remove it.
 Object pop()
          Pops the top element off of the stack and returns it to the calling application.
 void push(Object item)
          Adds the given item to the top of the stack
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Stack

public Stack()
Constructs a new stack object, initializing the stack to be empty
Method Detail

push

public void push(Object item)
Adds the given item to the top of the stack
Parameters:
item - The item to be added to the stack

isEmpty

public boolean isEmpty()
Tells whether or not the stack is empty
Returns:
True if the stack is empty, false if the stack is not empty.

peek

public Object peek()
           throws java.util.EmptyStackException
Returns the top element on the stack to the calling application, but does not remove it. Throws exception if the stack is empty
Returns:
The item that is the top element on the stack

pop

public Object pop()
          throws java.util.EmptyStackException
Pops the top element off of the stack and returns it to the calling application. Throws exception if stack is empty.
Returns:
The item that was the top element on the stack