Skip to content
Snippets Groups Projects
Commit bf43b1ee authored by Christopher Bohn's avatar Christopher Bohn :thinking:
Browse files

robust pop()

parent 4ae79849
Branches
Tags
No related merge requests found
import java.util.EmptyStackException;
public class MyStack {
private Node top;
......@@ -16,6 +18,7 @@ public class MyStack {
}
public Object pop() {
if (size() == 0) throw new EmptyStackException();
Object payload = top.getPayload();
top = top.getPrevious();
return payload;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment