| Modifier and Type | Field and Description |
|---|---|
protected int |
size |
protected Node<E> |
top |
| Constructor and Description |
|---|
NodeStack()
Creates an empty stack.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
isEmpty()
Return whether the stack is empty.
|
E |
pop()
pop() remove the head node of the list
|
void |
push(E element)
The new element is added in the front of the list
|
int |
size()
Return the number of elements in the stack.
|
E |
top()
Inspect the element at the top of the stack.
|
java.lang.String |
toString()
Returns a string representation of the stack as a list of elements.
|
public int size()
Stackpublic boolean isEmpty()
Stackpublic void push(E element)
public E top() throws EmptyStackException
Stacktop in interface Stack<E>EmptyStackException - if the stack is empty.public E pop() throws EmptyStackException
pop in interface Stack<E>EmptyStackException - if the stack is empty.public java.lang.String toString()
toString in class java.lang.Object