title: How to get ArrayList<Integer> and Scanner to play nice?
body: <pre><code>import java.util.*;
  
  public class CyclicShiftApp{
  
     public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        ArrayList&lt;Integer&gt; list = new ArrayList&lt;Integer&gt;();
        while(scan.hasNextInt()){
           list.add(scan.nextInt());
        }
        Integer[] nums = new  Integer[list.size()];
        nums = list.toArray(nums);
        for(int i = 0;i &lt; nums.length; i++){
        System.out.println(nums[i]);
        }   
  }
  </code></pre>
  
  <p>Thanks to poor-mans-debugging I've found that the <code>while(scan.hasNextInt())</code> isnt actually adding anything. What might be going wrong? Is my google-fu weak or lack of know-how letting me down? I am rather new to programming, and so unfamiliar with Lists so thought this would be a nice first step but something isnt adding up. It also compiles fine so Its not syntax(anymore). Perhaps a casting issue?</p>