public class SimpleStack extends ArrayList
add a new element to the top of the stackremove and return the element on the top of the stackreturn the element on the top of the stackStack except that it extends
ArrayList rather than Vector and is
therefore not thread safe. The top of the stack corresponds to the last
element in the underlying list, whereas the bottom corresponds to the first.
The SimpleStack implementation supports null elements; however, if null
elements are added, care must be taken to distinguish a null element returned
from pop() or peek() from a null value that indicates the
stack is empty.
modCount| Constructor and Description |
|---|
SimpleStack()
Create a new empty SimpleStack.
|
SimpleStack(int nCapacity)
Create a new empty SimpleStack with the specified initial capacity.
|
| Modifier and Type | Method and Description |
|---|---|
Object |
peek()
Return the object that is currently on top of the stack.
|
Object |
pop()
Remove and return the object that is currently on top of the stack.
|
void |
push(Object oElement)
Add the given object to the top of the stack.
|
add, add, addAll, addAll, clear, clone, contains, ensureCapacity, forEach, get, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, removeIf, removeRange, replaceAll, retainAll, set, size, sort, spliterator, subList, toArray, toArray, trimToSizeequals, hashCodecontainsAll, toStringfinalize, getClass, notify, notifyAll, wait, wait, waitcontainsAll, equals, hashCodeparallelStream, streampublic SimpleStack()
public SimpleStack(int nCapacity)
nCapacity - the initial capacity of the underlying list used to
store elementspublic void push(Object oElement)
oElement - the object to place on top of the stackpublic Object pop()
public Object peek()