java.util
Class Stack

java.lang.Object
  |
  +--java.util.Vector
        |
        +--java.util.Stack
All Implemented Interfaces:
Cloneable

public class Stack
extends Vector

A Last-In-First-Out(LIFO) stack of objects.


Field Summary
 
Fields inherited from class java.util.Vector
capacityIncrement, elementCount, elementData
 
Constructor Summary
Stack()
           
 
Method Summary
 boolean empty()
          Returns true if the stack is empty.
 Object peek()
          Peeks at the top of the stack.
 Object pop()
          Pops an item off the stack.
 Object push(Object item)
          Pushes an item onto the stack.
 int search(Object o)
          Sees if an object is on the stack.
 
Methods inherited from class java.util.Vector
addElement, capacity, clone, contains, copyInto, elementAt, elements, ensureCapacity, firstElement, indexOf, indexOf, insertElementAt, isEmpty, lastElement, lastIndexOf, lastIndexOf, removeAllElements, removeElement, removeElementAt, setElementAt, setSize, size, toString, trimToSize
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Stack

public Stack()
Method Detail

push

public Object push(Object item)
Pushes an item onto the stack.

Parameters:
item - the item to be pushed on.

pop

public Object pop()
Pops an item off the stack.

Throws:
EmptyStackException - If the stack is empty.

peek

public Object peek()
Peeks at the top of the stack.

Throws:
EmptyStackException - If the stack is empty.

empty

public boolean empty()
Returns true if the stack is empty.


search

public int search(Object o)
Sees if an object is on the stack.

Parameters:
o - the desired object
Returns:
the distance from the top, or -1 if it is not found.