title: Not able to recover from InputMismatchException
body: <p>I am learning about java try catch and using the following code</p>
  
  <pre><code>public static void main(String[] args) {
  
      Scanner in = null;
      int i = 0;
  
      try {
          in = new Scanner(System.in);
          System.out.print("Enter a number: ");
          i = in.nextInt();
      } catch (InputMismatchException ex) {
          System.out.printf("%nPlease enter a number: %d", in.nextInt());
      } finally {
          if (in != null) {
              System.out.println();
              System.out.println("Finally block !!!");
              in.close();
          }
      }
  
  }
  </code></pre>
  
  <p>Running those program and input a string return java with stack trace and exit (not asking for user to input correct number).
  If i remove in.nextInt() inside catch block, I do not see stack trace but not asking for user input too - exit immediately.</p>
  
  <p>I can't figure it out what is wrong with my code</p>