java.util
Class Stack
java.lang.Object
|
+--java.util.AbstractCollection
|
+--java.util.AbstractList
|
+--java.util.Vector
|
+--java.util.Stack
public class
Stackextends
VectorStack
public Stack()
This constructor creates a new Stack, initially empty
empty
public synchronized boolean empty()
Tests if the stack is empty.
Returns:
- true if the stack contains no items, false otherwise
peek
public synchronized Object peek()
Returns the top Object on the stack without removing it.
Returns:
- the top Object on the stack
Throws:
pop
public synchronized Object pop()
Pops an item from the stack and returns it. The item popped is
removed from the Stack.
Returns:
- the Object popped from the stack
Throws:
push
public Object push(java.lang.Object item)
Pushes an Object onto the top of the stack. This method is effectively
the same as addElement(item).
Parameters:
Returns:
- the Object pushed onto the stack
See Also:
search
public synchronized int search(java.lang.Object o)
Returns the position of an Object on the stack, with the top
most Object being at position 1, and each Object deeper in the
stack at depth + 1.
Parameters:
Returns:
- The 1 based depth of the Object, or -1 if the Object
is not on the stack