title: How can I not allow user input if it is not an int using a scanner?
body: <p>I am a very new programmer and I just learned about scanner, but I am trying to find a way to make it so when I press the up or down keys, it cycles through the options, putting a > in front to know that it is the option currently selected.</p>
  
  <p>This is the prompt:</p>
  
  <pre><code>What would you like to do:  
  Attack   
  Inventory  
  Stats  
  Flee
  </code></pre>
  
  <p>I would like it to have an arrow in front of the selected one and change the selection with the up and down arrow keys. So for example, as soon as you are prompted it looks like this:</p>
  
  <p>What would you like to do:  </p>
  
  <pre><code>What would you like to do:  
  &gt; Attack   
  Inventory  
  Stats  
  Flee
  </code></pre>
  
  <p>And if you pressed the down arrow key twice:</p>
  
  <pre><code>What would you like to do:  
  Attack   
  Inventory  
  &gt; Stats  
  Flee
  </code></pre>
  
  <p>So my current code looks like this:</p>
  
  <pre><code>public class Prompter {
  
      Scanner input = new Scanner(System.in);
      public int options() throws IOException {
          System.out.printf("What would you like to do:%nAttack %n Inventory %n Stats %n Flee %n");
          while (!input.hasNextInt()) input.next();
          int choice = input.nextInt();
          System.out.printf("Choice: %d", choice);
      return choice;
      }
  }
  </code></pre>
  
  <p>What it does right now is accepts an int input and returns it.</p>
  
  <p>Please do not send me a huge block of code without explaining it because I am a pretty new programmer. Thanks! </p>