Class java.util.Stack
All Packages Class Hierarchy This Package Previous Next Index
Class java.util.Stack
java.lang.Object
|
+----java.util.Vector
|
+----java.util.Stack
- public class Stack
- extends Vector
A Last-In-First-Out(LIFO) stack of objects.
-
Stack()
-
-
empty()
- Returns true if the stack is empty.
-
peek()
- Peeks at the top of the stack.
-
pop()
- Pops an item off the stack.
-
push(Object)
- Pushes an item onto the stack.
-
search(Object)
- Sees if an object is on the stack.
Stack
public Stack()
push
public Object push(Object item)
- Pushes an item onto the stack.
- Parameters:
- item - the item to be pushed on.
pop
public Object pop()
- Pops an item off the stack.
- Throws: EmptyStackException
- If the stack is empty.
peek
public Object peek()
- Peeks at the top of the stack.
- Throws: EmptyStackException
- If the stack is empty.
empty
public boolean empty()
- Returns true if the stack is empty.
search
public int search(Object o)
- Sees if an object is on the stack.
- Parameters:
- o - the desired object
- Returns:
- the distance from the top, or -1 if it is not found.
All Packages Class Hierarchy This Package Previous Next Index