加载中...
The Wayback Machine - https://sup1a9wrlpyh5li9ro.vcoronado.top/web/20090218195536/http://developer.android.com:80/reference/java/util/Stack.html
public class

Stack

extends Vector<E>
java.lang.Object
   ↳ java.util.AbstractCollection<E>
     ↳ java.util.AbstractList<E>
       ↳ java.util.Vector<E>
         ↳ java.util.Stack<E>

Class Overview

Stack is a Last-In/First-Out(LIFO) data structure which represents a stack of objects. It enables users to pop and push onto the stack, including null objects. There is no limit to the size of the stack

Summary

[Expand]
Inherited Fields
From class java.util.Vector
From class java.util.AbstractList
Public Constructors
Stack()
Constructs a stack with the default size of Vector.
Public Methods
boolean empty()
Determines if the stack is empty or not.
synchronized E peek()
Returns the element at the top of the stack without removing it.
synchronized E pop()
Returns the element at the top of the stack and removes it.
synchronized E push(E object)
Pushes the object from the parameter onto the top of the stack.
synchronized int search(Object o)
Returns the index of the first occurrence of the object.
[Expand]
Inherited Methods
From class java.util.Vector
From class java.util.AbstractList
From class java.util.AbstractCollection
From class java.lang.Object
From interface java.lang.Iterable
From interface java.util.Collection
From interface java.util.List

Public Constructors

public Stack ()

Constructs a stack with the default size of Vector.

Public Methods

public boolean empty ()

Determines if the stack is empty or not.

Returns
  • true if the stack is empty, false otherwise

public synchronized E peek ()

Returns the element at the top of the stack without removing it.

Returns
  • the element at the top of the Stack
Throws
EmptyStackException when empty() is true
See Also

public synchronized E pop ()

Returns the element at the top of the stack and removes it.

Returns
  • the element at the top of the stack.
Throws
EmptyStackException when empty() is true
See Also

public synchronized E push (E object)

Pushes the object from the parameter onto the top of the stack.

Parameters
object The object to be added to the stack
Returns
  • the object argument
See Also

public synchronized int search (Object o)

Returns the index of the first occurrence of the object.

Parameters
o the object to be searched
Returns
  • the index of the first occurrence of the object