I read line with
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); reader.readLine();
Example input is
Since you don't know the size of input, you can read input as string and then parse the string array to integer array
String[] arr=reader.readLine().split(" "); int[] intarr=new int[arr.length]; for(int i=0;i