Why does the while loop only take inputs of multiple 2? : <pre><code>package hw6;
import java.util.Scanner;
import java.util.ArrayList;

public class hw6q1 {

    public static void main(String[] args) {
        ArrayList&lt;Integer&gt; al = new ArrayList&lt;Integer&gt;();
        Scanner input = new Scanner(System.in);
        System.out.println("Enter integers between 1 and 100 (enter 0 to 
stop):");
        while(input.nextInt() != 0){
            al.add(input.nextInt());
        }
        input.close();
        for(int i = 0; i &lt; al.size(); i++){
            System.out.println(al.get(i));
        }



    }

}
</code></pre>

<p>So that is my code and when I run the program and give in the numbers 1 2 3 4 then 0 to end the loop it only prints 2 and 4. I was wondering why that is the case and how to fix it so that the arraylist gets all the number 1 2 3 and 4. </p>
