title: How to insist that a users input is an int?
body: <p>Basic problem here..  I will start off by asking that you please not respond with any code, as that likely will only confuse me further (programming noob).  I am looking for a clear explanation on how to solve this issue that I'm having.</p>
  
  <p>I have a scanner that reads input from the user. The user is prompted to enter an int value between 1 to 150 (whole numbers only). I obtain the value as follows:</p>
  
  <pre><code>    Scanner scan = new Scanner(System.in);
      int input = scan.nextInt();
  </code></pre>
  
  <p>And continue on with my program, and everything works fine.</p>
  
  <p>Unfortunately, the code isn't exactly bulletproof, since any input that is not an integer can break it (letters, symbols, etc).</p>
  
  <p>How can I make the code more robust, where it would verify that only an int was entered?</p>
  
  <p>These are the results I'm hoping for:</p>
  
  <p>Lets say the input was:</p>
  
  <pre><code>23 -&gt; valid
  fx -&gt; display an error message, ask the user for input again (a while loop would do..)
  7w -&gt; error, again
  3.7 -&gt; error
  $$ -&gt; error
  etc
  </code></pre>