title: Filtering java.util.Scanner input?
body: <p>I'm using a <code>java.util.Scanner</code>, and I want to filter out user input if it is out of range, for example only accept 0, 1, 2 or 3. Perhaps something like:</p>
  
  <pre><code>if !(sc.hasNextInt 0,1,2,3
  </code></pre>
  
  <p>I'm aware this isn't valid syntax, but I wanted to show what I was going for. How do I tell Java not to store user input that doesn't meet my criteria?</p>