Created
March 31, 2013 18:16
-
-
Save hawkw/5281500 to your computer and use it in GitHub Desktop.
this works real good you guys!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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