title: No exception of type UnderflowException can be thrown;
body: <p>I am trying to implement a stack with some functions in Java. I have created the class UnderflowException that implements Exception like this:</p>
  
  <pre><code>package exceptions;
  
  public class UnderflowException extends Exception
  {
      public UnderflowException(String err)
      {
          super(err);
      }
  }
  </code></pre>
  
  <p>When I'm implementing the Interface I get the following error
  <strong>"No exception of type UnderflowException can be thrown; an exception type must be a class of Throwable"</strong> when I try to throw.</p>
  
  <p>My interface looks like this:</p>
  
  <pre><code>import exceptions.*;
  public interface Stack
  {
      public void push(Object x);
      public void pop() throws UnderflowException;
      public Object top() throws UnderflowException;
      //other functions
  }
  </code></pre>
  
  <p>Is there a problem with the UnderflowException class? Thank you!</p>