I read line with
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
reader.readLine();
Example input is
Scanner sc = new Scanner(System.in);
String n=sc.nextLine();
String[] no=n.split(" ");
int sum=0;
for(String i:no){
sum+=Integer.parseInt(i);}
System.out.println(sum);
The Above code is how can you take space separate integer inputs using java programming and perform any task of your choice in my case I have added the numbers.