Name

java.util.Stack

Synopsis

This class is identical to the J2SE Stack class. It extends the Vector class to allow a simple Last-In-First-Out (LIFO) stack, where elements are placed on the top of the stack using the push() method and removed from the top using the pop() method. peek() returns the object at the top of the stack without actually removing it. search() will search the stack for the specified object, returning the index of the element if found or -1 if it is not found.

public classStack extends java.util.Vector {
   // constructor
   public Stack();

   // public instance methods
   public boolean empty();
   public Object peek();
   public Object pop();
   public Object push(Object item);
   public int search(Object o);
}

Get Wireless Java now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.