title: How to capture non-integers in this Java program
body: <p>How do I add a try-catch piece of code to stop someone from entering <code>chars</code> or, as a matter of fact, anything other than an <code>int</code> from <code>1 - 5</code>?</p>
  
  <pre><code>boolean valid;
  int option = 0;
  
  do {
      Scanner in = new Scanner(System.in); // need try catch
      menu();
      System.out.println("\n");
      option = in.nextInt();
  
      valid = option &gt; 0 &amp;&amp; option &lt; 6; // try / catch needed around here?
  
  } while(!valid); // stop chars and strings being entered
  // I want to stop the user entering anything other than an int 1-5
  </code></pre>