Interface Stack


public interface Stack

Provides a LIFO (last-in-first-out) storage.

Author:
Christian Liebchen

Method Summary
 boolean isEmpty()
          Tells whether this stack contains an object.
 Object pop()
          Provides the top-object of this stack and removes it from the stack.
 void push(Object o)
          Adds a new object at the top of this stack.
 Object top()
          Provides the top-object of this stack without removing it.
 

Method Detail

isEmpty

public boolean isEmpty()
Tells whether this stack contains an object.

Returns:
true, iff this stack does not contain any object

push

public void push(Object o)
Adds a new object at the top of this stack.

Parameters:
o - the object to be stored in this stack

top

public Object top()
           throws EmptyStackException
Provides the top-object of this stack without removing it.

Returns:
the top object in this stack
Throws:
EmptyStackException - if isEmpty()

pop

public Object pop()
           throws EmptyStackException
Provides the top-object of this stack and removes it from the stack.

Returns:
the top object in this stack
Throws:
EmptyStackException - if isEmpty()