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
The Stack class represents a last-in-first-out (LIFO) stack of objects.


Constructor Index

 o Stack()

Method Index

 o empty()
Tests if this stack is empty.
 o peek()
Looks at the object at the top of this stack without removing it from the stack.
 o pop()
Removes the object at the top of this stack and returns that object as the value of this function.
 o push(Object)
Pushes an item onto the top of this stack.
 o search(Object)
Returns where an object is on this stack.

Constructors

 o Stack
public Stack()

Methods

 o push
public 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.
 o pop
public synchronized 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.
 o peek
public synchronized 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.
 o empty
public boolean empty()
Tests if this stack is empty.

Returns:
true if this stack is empty; false otherwise.
 o 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.

All Packages  Class Hierarchy  This Package  Previous  Next  Index

Submit a bug or feature - Version 1.1.8 of Java Platform API Specification
Java is a trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries.
Copyright 1995-1999 Sun Microsystems, Inc. 901 San Antonio Road,
Palo Alto, California, 94303, U.S.A. All Rights Reserved.