E
- the type of items in our stack.public class MyStack<E>
extends java.lang.Object
Constructor and Description |
---|
MyStack() |
Modifier and Type | Method and Description |
---|---|
boolean |
isEmpty()
Return whether or not this stack is empty.
|
E |
peek()
Return (but do not remove) the top item in the stack.
|
E |
pop()
Remove and return the top item in the stack.
|
void |
push(E item)
Push the given item onto the top of the stack.
|
java.lang.String |
toString()
Returns a string beginning and ending with left and right square brackets, respectively, and containing a comma separated list of stack elements ordered from the top of the stack to the bottom of the stack.
|
public boolean isEmpty()
public E pop()
public E peek()
public void push(E item)
item
- the item to be pushed onto the stackpublic java.lang.String toString()
toString
in class java.lang.Object