| Package java.util |
Previous |
Java API |
Index |
Next |
public class java.util.Stack
extends java.util.Vector
{
// Constructors
public Stack();
// Methods
public boolean empty();
public Object peek();
public Object pop();
public Object push(Object item);
public int search(Object o);
}
The Stack class represents a last-in-first-out (LIFO) stack of objects.
public Stack()Creates a new stack with no elements.
public boolean empty()Return Value:
Returns true if this stack is empty; false otherwise.
public Object peek()Looks at the object at the top of this stack without removing it from the stack.
Return Value:
Returns the object at the top of this stack.
Throw:
If this stack is empty.
public Object pop()Removes the object at the top of this stack and returns that object as the value of this function.
Return Value:
Returns The object at the top of this stack.
Throw:
If this stack is empty.
public Object push(Object item)Pushes an item onto the top of this stack.
Return Value:
Returns the item argument.
Parameter Description item the item to be pushed onto this stack.
public int search(Object o)Determines if an object is on this stack.
Return Value:
Returns The distance from the top of the stack that at which the object is located at; the return value -1 indicates that the object is not on the stack.
Parameter Description o the desired object
| © 1996 Sun Microsystems, Inc. All rights reserved. |