java.util.Stack<E>
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
protected |
|
|
int |
capacityIncrement |
How many elements should be added to the vector when it is detected that
it needs to grow to accommodate extra entries. |
protected |
|
|
int |
elementCount |
The number of elements or the size of the vector. |
protected |
|
|
Object[] |
elementData |
The elements of the vector. |
Public Constructors
Public Methods
add,
add,
addAll,
addAll,
addElement,
capacity,
clear,
clone,
contains,
containsAll,
copyInto,
elementAt,
elements,
ensureCapacity,
equals,
firstElement,
get,
hashCode,
indexOf,
indexOf,
insertElementAt,
isEmpty,
lastElement,
lastIndexOf,
lastIndexOf,
remove,
remove,
removeAll,
removeAllElements,
removeElement,
removeElementAt,
removeRange,
retainAll,
set,
setElementAt,
setSize,
size,
subList,
toArray,
toArray,
toString,
trimToSize
add,
add,
addAll,
clear,
equals,
get,
hashCode,
indexOf,
iterator,
lastIndexOf,
listIterator,
listIterator,
remove,
removeRange,
set,
subList
add,
addAll,
clear,
contains,
containsAll,
isEmpty,
iterator,
remove,
removeAll,
retainAll,
size,
toArray,
toArray,
toString
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait
add,
addAll,
clear,
contains,
containsAll,
equals,
hashCode,
isEmpty,
iterator,
remove,
removeAll,
retainAll,
size,
toArray,
toArray
Methods inherited
from interface
java.util.List
add,
add,
addAll,
addAll,
clear,
contains,
containsAll,
equals,
get,
hashCode,
indexOf,
isEmpty,
iterator,
lastIndexOf,
listIterator,
listIterator,
remove,
remove,
removeAll,
retainAll,
set,
size,
subList,
toArray,
toArray
Details
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
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.
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 |
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