E
- the element type to store in this stackpublic class Stack<E> extends Object
Constructor and Description |
---|
Stack()
Creates an empty stack (size equal to zero).
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object obj)
Compares the specified object to this stack for equality.
|
Node<E> |
getTop()
Returns the node at the top of the stack.
|
int |
hashCode()
Returns a hash code for this stack.
|
boolean |
isEmpty()
Returns true if this stack is empty, and false otherwise.
|
E |
peek()
Returns the element that is on the top of this stack without popping it
from the stack.
|
E |
pop()
Pop an element from the top of the stack returning the element.
|
void |
push(E element)
Push an element onto the top of the stack.
|
int |
size()
Get the size (number of elements) in the stack.
|
String |
toString()
Returns a string representation of this stack.
|
public boolean isEmpty()
public int size()
public void push(E element)
element
- the element to push onto the stackpublic E pop()
NoSuchElementException
- if the stack is emptypublic E peek()
NoSuchElementException
- if the stack is emptypublic boolean equals(Object obj)
equals
in class Object
Object.equals(java.lang.Object)
obj
- the object to compare to this stack for equalitypublic int hashCode()
hashCode
in class Object
Object.hashCode()
public String toString()
toString
in class Object
Object.toString()