I am using:
Scanner input = new Scanner(System.in)
For (int i + 0; i < 10; i++){
while(input.hasNextLine()){
String data = input.nextLine();
}
}
Repeated calls to hasNextLine() beyond the first cause the while loop to fail.
I tried the following:
Scanner input;
For (int i = 0; i < 10, i ++){
input = new Scanner(System.in);
while(input.hasNextLine()){
String data = input.nextLine();
}
input.close();
}
It was, as you can guess, not successful. Essentially, once Scanner has moved to the end of the buffer and is at EOF, and further hasNextLine() produces false.
however, hasNextLine() is supposed to block for input so why it does not and allow further input is beyond my understanding.