The nextInt
method does not consume the new line character after the integer so when you call nextLine
it just reads the new line character immediately following the integer.
Example
If you have this input:
42\n
foo\n
The readInt
call consumes the 42
but not the new line character:
\n
foo\n
Now when you call readLine
it consumes the rest of the first line, which contains only the new line character.
Solution
Try discarding the rest of the line after the integer:
int bla = scanner.nextInt();
scanner.nextLine(); // Discard the rest of the line.
String blubb = scanner.nextLine();
Or use nextLine
consistently to read each line and then parsing the string to an integer yourself:
String blaString = scanner.nextLine();
int bla = Integer.valueOf(blaString);
String blubb = scanner.nextLine();