title: Easier way to guarantee integer input through Scanner?
body: <p>For a program I am writing, I need to ask a user for an integer between 1 and 8. I've tried multiple (cleaner) ways of doing this but none of them worked, so I'm left with this:</p>
  
  <pre><code>    int x = 0;
      while (x &lt; 1 || x &gt; 8)
      {   
          System.out.print("Please enter integer  (1-8): ");
  
          try
          {
              x = Integer.parseInt(inputScanner.next());
          }
          catch(NumberFormatException e)
          {
              x = 0;
          }
      }
  </code></pre>
  
  <p>Where <code>inputScanner</code> is a  Scanner. Surely there is a better way?</p>