title: Scanner inside a loop - Why does it not exit loop when incorrect input is entered?
body: <p>The code -</p>
  
  <pre><code>for(int i = 0; i &lt; count; i++)
      {
       System.out.println("Please enter a number!");
      try{
           numbers[i] = keyboardScanner.nextInt();
      }catch(InputMismatchException ex)
      {
        System.out.println("You did not enter a number!");
      }
  }
  </code></pre>
  
  <p>If you enter a String, it loops till 'count'. Why does that happen ? </p>