title: Error catching with try-catch and while loop
body: <p>I'm trying to make sure that the users input is an integer but when I use the below code I just get an infinite loop of the <code>print</code> statement. Any advice of how to improve?</p>
  
  <pre><code>boolean valid = false;
  System.out.println("What block are you gathering? (use minecraft block ids)");
  while(valid == false){
      try{
          block = input.nextInt();
          valid = true;
      }
      catch(InputMismatchException exception){
          System.out.println("What block are you gathering? (use minecraft block ids)");
          valid = false;
      }
  }
  </code></pre>