/** * Removes the element on the top of the stack. * * @return the removed element * @throws EmptyStackException if the stack is empty */ public Object remove() { int size = size(); if (size == 0) { throw new EmptyStackException(); } return remove(size - 1); }
/** * Removes the element on the top of the stack. * * @return the removed element * @throws EmptyStackException if the stack is empty */ public Object remove() { int size = size(); if (size == 0) { throw new EmptyStackException(); } return remove(size - 1); }
/** * Pops the top item off of this stack and return it. * * @return the top item on the stack * @throws EmptyStackException if the stack is empty */ public Object pop() throws EmptyStackException { int n = size(); if (n <= 0) { throw new EmptyStackException(); } else { return remove(n - 1); } }
/** * Pops the top item off of this stack and return it. * * @return the top item on the stack * @throws EmptyStackException if the stack is empty */ public Object pop() throws EmptyStackException { int n = size(); if (n <= 0) { throw new EmptyStackException(); } else { return remove(n - 1); } }