diff --git a/DataStructures/Stacks/Stacks.java b/DataStructures/Stacks/Stacks.java index 2861ef5c..455c67e8 100644 --- a/DataStructures/Stacks/Stacks.java +++ b/DataStructures/Stacks/Stacks.java @@ -53,18 +53,16 @@ class Stack{ * @return value popped off the Stack */ public int pop(){ - if(!isEmpty()){ //Checks for an empty stack - return stackArray[top--]; + if(isEmpty()){ //Checks for an empty stack + System.out.println("The stack is already empty"); + return -1; } if(top < maxSize/4){ resize(maxSize/2); - return pop();// don't forget pop after resizing - } - else{ - System.out.println("The stack is already empty"); - return -1; } + + return stackArray[top--]; } /**