Name
Stack<E>
Synopsis
This class implements
a last-in-first-out (LIFO) stack of objects. push(
)
puts an object on the top of the stack. pop(
)
removes and returns the top object from the stack.
peek( )
returns the top object without removing
it. In Java 1.2, you can instead use a LinkedList
as a stack.
Figure 16-58. java.util.Stack<E>
public class Stack<E> extends Vector<E> { // Public Constructors public Stack( ); // Public Instance Methods public boolean empty( ); public E peek( ); synchronized public E pop( ); synchronized public E push(E item); public int search(Object o); synchronized }
Get Java in a Nutshell, 5th Edition 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.