T
- The type of data that the stack stores.public interface Stack<T>
Modifier and Type | Interface and Description |
---|---|
static class |
Stack.EmptyStackException
An exception to indicate that the stack is empty on pop or peek.
|
Modifier and Type | Method and Description |
---|---|
void |
clear()
Removes all items from the stack.
|
boolean |
isEmpty()
Returns true if the stack is empty.
|
T |
peek()
Returns the item on top of the stack, without removing it.
|
T |
pop()
Removes the item from the top of this stack, and returns it.
|
void |
push(T item)
Adds an item to the top of this stack.
|
void push(T item)
T pop()
Stack.EmptyStackException
- if the stack is empty.T peek()
Stack.EmptyStackException
- if the stack is empty.boolean isEmpty()
void clear()