How to get ArrayList<Integer> and Scanner to play nice?
import java.util.*; public class CyclicShiftApp{ public static void main(String[] args){ Scanner scan = new Scanner(System.in); ArrayList<Integer> list = new ArrayList<Integer>(); while(scan.hasNextInt()){ list.add(scan.nextInt()); } Integer[] nums = new Integer[list.size()]; nums = list.toArray(nums); for(int i = 0;i < nums.length; i++){ System.out.println(nums[i]); } } Thanks to poor-mans-debugging I've found that the while(scan.hasNextInt()) 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