示例#1
0
 @Override
 public E top() throws EmptyStackException {
   if (isEmpty()) {
     throw new EmptyStackException("Stack is empty!");
   }
   return top.getElement();
 }
示例#2
0
 @Override
 public E pop() throws EmptyStackException {
   if (isEmpty()) {
     throw new EmptyStackException("Stack is empty");
   }
   E element = top.getElement();
   top = top.getNext();
   size--;
   return element;
 }