The Stack class represents a last-in-first-out
(LIFO) stack of objects. It extends class Vector with five
operations that allow a vector to be treated as a stack. The usual
push and pop operations are provided, as well as a
method to peek at the top item on the stack, a method to test
for whether the stack is empty, and a method to search
the stack for an item and discover how far it is from the top.
When a stack is first created, it contains no items.
Returns the 1-based position where an object is on this stack.
If the object o occurs as an item in this stack, this
method returns the distance from the top of the stack of the
occurrence nearest the top of the stack; the topmost item on the
stack is considered to be at distance 1. The equals
method is used to compare o to the
items in this stack.
Parameters:
o - the desired object.
Returns:
the 1-based position from the top of the stack where
the object is located; the return value -1
indicates that the object is not on the stack.
Submit a bug or feature For further API reference and developer documentation, see Java 2 SDK SE Developer Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Java, Java 2D, and JDBC are trademarks or registered trademarks of Sun Microsystems, Inc. in the US and other countries. Copyright 1993-2001 Sun Microsystems, Inc. 901 San Antonio Road Palo Alto, California, 94303, U.S.A. All Rights Reserved.