Code example for EmptyStackException

0
  /** 
   * @return the int at the top of the stack 
   */ 
  public int peek() throws EmptyStackException { 
    if (isEmpty()) { 
      throw new EmptyStackException();
    } 
    return state[top];
  } 
 
  /** 
   * pop the stack 
   * @return the int at the top of the stack 
   */ 
  public int pop() throws EmptyStackException{ 
    if (isEmpty()) { 
      throw new EmptyStackException();
    } 
    return state[top--];
  }