Skip to content

Instantly share code, notes, and snippets.

@hawkw
Created March 31, 2013 18:16
Show Gist options
  • Save hawkw/5281500 to your computer and use it in GitHub Desktop.
Save hawkw/5281500 to your computer and use it in GitHub Desktop.
this works real good you guys!
public E peek () throws EmptyStackException {
if (empty())
throw new EmptyStackException();
return stack[top];
}
public E pop () throws EmptyStackException {
if (empty())
throw new EmptyStackException();
E element = stack[top];
stack[top--] = null;
return element;
}
public boolean empty () {
if (empty()) { // recursion!
return true;
} else {
return false;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment