Class java.util.Stack
All Packages Class Hierarchy This Package Previous Next Index
Class java.util.Stack
Object
|
+----Vector
|
+----java.util.Stack
- public class Stack
- extends Vector
The Stack
class represents a last-in-first-out
(LIFO) stack of objects.
- Version:
- 1.17, 07/01/98
- Author:
- Jonathan Payne
- Since:
- JDK1.0
-
java.util.Stack()
-
-
empty()
- Tests if this stack is empty.
-
peek()
- Looks at the object at the top of this stack without removing it
from the stack.
-
pop()
- Removes the object at the top of this stack and returns that
object as the value of this function.
-
push(Object)
- Pushes an item onto the top of this stack.
-
search(Object)
- Returns where an object is on this stack.
Stack
public Stack()
empty
public boolean empty()
- Tests if this stack is empty.
- Returns:
-
true
if this stack is empty;
false
otherwise.
- Since:
- JDK1.0
peek
public synchronized java.lang.Object peek()
- Looks at the object at the top of this stack without removing it
from the stack.
- Returns:
- the object at the top of this stack.
- Throws: EmptyStackException
- if this stack is empty.
- Since:
- JDK1.0
pop
public synchronized java.lang.Object pop()
- Removes the object at the top of this stack and returns that
object as the value of this function.
- Returns:
- The object at the top of this stack.
- Throws: EmptyStackException
- if this stack is empty.
- Since:
- JDK1.0
push
public java.lang.Object push(Object item)
- Pushes an item onto the top of this stack.
- Parameters:
- item - the item to be pushed onto this stack.
- Returns:
- the
item
argument.
- Since:
- JDK1.0
search
public synchronized int search(Object o)
- Returns where an object is on this stack.
- Parameters:
- o - the desired object.
- Returns:
- the distance from the top of the stack where the object is]
located; the return value
-1
indicates that the
object is not on the stack.
- Since:
- JDK1.0
All Packages Class Hierarchy This Package Previous Next Index