Class Stack

java.lang.Object
  |
  +--Stack

public class Stack
extends java.lang.Object

Stack implements a stack of non-null objects. The stack is implemented as a conslist.


Constructor Summary
Stack()
          Constructs the empty stack.
 
Method Summary
 void clear()
          Clears the stack.
 boolean empty()
          Reports if the stack is empty.
 java.lang.Object peek()
          Peeks at the object at the top of the stack without removing it.
 java.lang.Object pop()
          Removes the object at the top of the stack.
 void push(java.lang.Object obj)
          Adds an object to the stack.
 int size()
          The number of elements on 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 the empty stack.
Method Detail

push

public void push(java.lang.Object obj)
Adds an object to the stack.
Parameters:
obj - the object that will be pushed onto the stack.

pop

public java.lang.Object pop()
Removes the object at the top of the stack.
Returns:
The object at the top of the stack, or null if the stack is empty.

peek

public java.lang.Object peek()
Peeks at the object at the top of the stack without removing it.
Returns:
The object at the top of the stack, or null if the stack is empty.

empty

public boolean empty()
Reports if the stack is empty.
Returns:
true if the stack is empty, false otherwise.

size

public int size()
The number of elements on the stack.
Returns:
the number of elements on the stack.

clear

public void clear()
Clears the stack.