-1
String s = in.next();

and

String s = in.nextLine();
Rishikesh Dhokare
  • 3,319
  • 20
  • 34

1 Answers1

0

next() can read the input only till the space. It can't read two words separated by a space. Also, next() places the cursor in the same line after reading the input.
nextLine() reads input including space between the words (that is, it reads till the end of line \n). Once the input is read, nextLine() positions the cursor in the next line.

Bimlendu Kumar
  • 212
  • 1
  • 13
  • Neither method has anything to do with spaces. That just happens to be the default token delimiter. – shmosel Feb 18 '18 at 07:22