title: java do while asked for input twice
body: <p>why do I need to input 2 times? please help I'm new to java, can't find the error</p>
  <pre class="lang-java prettyprint-override"><code>do {
      System.out.println(&quot;Enter your age: &quot;);
      age= in.nextInt();
      if(!in.hasNextInt()) {
          System.out.println(&quot;Please enter a valid age&quot;);
          in.nextInt();
          valid=false;
      }
  }while(valid);
  </code></pre>
  <p>I removed the do while but it still asks for the second input</p>
  <pre class="lang-java prettyprint-override"><code>System.out.println(&quot;Enter your age: &quot;);
  age= in.nextInt();
  if(!in.hasNextInt()) { //Will run till an integer input is found
      System.out.println(&quot;Please enter a valid age&quot;);
      in.nextInt();
      valid=false;
  }
  </code></pre>