I've got the following method:
public T peek() throws StackEmptyException {
Node<T> tracker = head;
while(tracker.getNext() != null) {
tracker = tracker.getNext();
}
return tracker.getItem();
}
The problem is that when I try to do something like
int firstOne = stack.peek();
I get an unreported exception StackEmptyException
and I have no idea what I'm doing wrong at this point. The StackEmptyException
has been made in a separate class. Am I suppose to have this class extend that new exception class I made? So confused. Thoughts guys?