I have distilled the following code from an exercise. I don't understand why nextLine() returns an empty
String:
Here is the output:
Enter an int
50
Enter a sentence -- spaces are allowed
Enter a String -- with no spaces
15
i = 50
s1 =
s2 = 15
The program didn't block and wait for nextLine() to have data, it seems to have just returned "" immediately. Why would this be and what is the right way to fix this problem?
Edit: By the way, I'm running a Mac if that makes a difference. Does this have anything to do with line-endings? Do I need to set a
pattern for line-endings in the Scanner object?