title: Why does this code not wait for input
body: <p>I expect the code to stop and wait for input again, but instead it runs as if the user just hit enter every time, creating a infinite loop.</p>
  
  <pre><code>while(asking) {
      try {   
          int answer = input.nextInt();   
      }
      catch(Exception InputMismatchException) { 
          System.out.println("Please only enter numbers.");
      }
  }
  </code></pre>
  
  <p>Why does it do this?</p>
  
  <p>EDIT: I am not worried about <em>exiting</em> the while loop. The problem is that it will not wait for input.</p>
  
  <p>EDIT2: It runs as expected if the exception isn't triggered. (I.E the user entered a number within the integer limit)</p>