jb
Class Stack

java.lang.Object
  |
  +--jb.Stack

public class Stack
extends java.lang.Object

The Stack class represents a last-in-first-out stack of objects.


Constructor Summary
Stack()
           
 
Method Summary
 boolean isEmpty()
          Tests if this stack is empty.
 java.lang.Object peek()
          Returns the object at the top of this stack without removing it.
 java.lang.Object pop()
          Removes the object at the top of this stack and returns that object.
 void push(java.lang.Object item)
          Pushes an item on to the top of this stack.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Stack

public Stack()
Method Detail

push

public void push(java.lang.Object item)
Pushes an item on to the top of this stack.
Parameters:
item - the item to be pushed.

pop

public java.lang.Object pop()
                     throws java.util.NoSuchElementException
Removes the object at the top of this stack and returns that object.
Returns:
The object at the top of this stack.
Throws:
java.util.NoSuchElementException - if this stack is empty.

peek

public java.lang.Object peek()
                      throws java.util.NoSuchElementException
Returns the object at the top of this stack without removing it.
Returns:
the object at the top of this stack.
Throws:
java.util.NoSuchElementException - if this stack is empty.

isEmpty

public boolean isEmpty()
Tests if this stack is empty.
Returns:
true if this stack is empty and false otherwise.