title: Java InputMismatchException
body: <p>I have this code and I want to catch the letter exception but it keeps having these errors:</p>
  
  <pre><code>Exception in thread "main" java.util.InputMismatchException
      at java.util.Scanner.throwFor(Scanner.java:840)
      at java.util.Scanner.next(Scanner.java:1461)
      at java.util.Scanner.nextInt(Scanner.java:2091)
      at java.util.Scanner.nextInt(Scanner.java:2050)
      at exercise_one.Exercise.main(Exercise.java:17)
  </code></pre>
  
  <p>And here is my code:</p>
  
  <pre><code> System.out.print("Enter the number of students: ");
  
   students = input.nextInt(); 
  
   while (students &lt;= 0) {
  
       try {
  
          System.out.print("Enter the number of students: ");
  
          students = input.nextInt();
  
       }
  
       catch (InputMismatchException e) {
  
          System.out.print("Enter the number of students");
  
       }
   }    
  </code></pre>