title: Java custom exception class
body: <p>I am having a rather trivial problem creating my own exception class. I have extending it and am trying to recieve a double in the constructor but I keep getting errors. </p>
  
  <p>Error inside of bankaccount @withdraw "incompatible types: InsufficientFundsException cannot be converted to throwable"</p>
  
  <p>Exception class:</p>
  
  <pre><code>    public class InsufficientFundsException extends RuntimeException {
  
      private double shortFall;   
  
      public InsufficientFundsException(double a) {
          super("Insufficient funds");
          shortFall = a;
      }
  
      public double getAmount() { return shortFall; }
  
  }
  </code></pre>
  
  <p>Bank Account class:</p>
  
  <pre><code>public class BankAccount {
  
      private int accountNumber;
      private double balance;
  
      // Class constructor
      public BankAccount(int account) {
          accountNumber = account;
          balance = 0.0;
      }
  
      public int getAccountNumber() {
  
          return accountNumber;
      }
  
      public double getBalance()
      {
          return balance;
      }
  
      public void deposit(double b) {
          balance += b;
      }
  
      public void withdraw(double w) throws InsufficientFundsException {
  
          double difference;
          if(w &gt; balance) {
              difference = w - balance;           
          } else {
              balance -= w;   
          }
      }
  </code></pre>
  
  <p>I would like to withdraw money unless the withdraw is greater than the current balance. In which case I want to throw an exception. I also tried to throw and exception inside of the if but I get:</p>
  
  <p>constructor InsufficientFundsException in class InsufficientFundsException cannot be applied to gived types;
  required: no arguments
  found: double
  reason: actual and formal argument lists differ in length</p>
  
  <pre><code> public void withdraw(double w)  {
  
          double difference;
          if(w &gt; balance) {
              difference = w - balance; 
              Exception ex =  new InsufficientFundsException(difference);
          } else {
              balance -= w;   
          }
      }
  </code></pre>
  
  <p>I only have the one constructor though. Any advice or help is appreciated.</p>