How can I read in one line of integers at a time before moving on to the next one?
I'm receiving input like below (ignore bullet points):
There might be better way and one possible way could be reading whole line as a single string and then splitting each on spaces. These will be string though and you have to change it to integer.
Scanner scanner = new Scanner(System.in); String str = scanner.nextLine(); String splitStr = str.split(" "); for(String s: splitStr) System.out.println(s);