title: Why is the list only adding certain numbers?
body: <p>I am trying to compile a list of int by asking the users for inputs. However, the code, for some reason, only adding even numbers to the list. Also, the while loop only stops when I input 999 the second time. The code is as follow:</p>
  
  <pre><code>import java.util.*;
  
  public class hw3 {
    public static void main (String args[]) {
      Scanner input = new Scanner(System.in);
      ArrayList&lt;Integer&gt; pre = new ArrayList&lt;Integer&gt;();
      while (input.nextInt() != 999) {
        pre.add(input.nextInt());
      }
    }
  }
  </code></pre>
  
  <p>I am not sure what I am doing wrong. Please point out my mistake. </p>