title: Java Scanner exception handling
body: <p>I would like to receive a Double from the user and handle the exception thrown in case the user didn't input a double/int; in that case I'd like to ask the user to insert the amount again. 
  My code gets stuck in a loop if the exception is caught, and keeps printing "Insert amount".</p>
  
  <pre><code>    private static double inputAmount() {
      Scanner input = new Scanner(System.in);
      while (true) {
          System.out.println("Insert amount:");
          try {
              double amount = input.nextDouble();
              return amount;
          }catch (java.util.InputMismatchException e) {continue;}
          }
      }
  </code></pre>
  
  <p>Thank you in advance.</p>