I am doing an exercise from an introduction to object-oriented programming with Java C. Thomas Wu.
Page 73 provides a code to request the full name, marks it with a separator, and prints it.
import java.util.*; class Scanner1 { public static void main(String[] args) { String name; Scanner scanner = new Scanner(System.in); scanner.useDelimiter(System.getProperty("line.separator")); System.out.print("Enter full name (first, middle, last)"); name = scanner.next( ); System.out.println("you entered " + name + "."); } }
The problem is that my version does not seem to want to print it, and it freezes the program, forcing it to use the task manager to close it.

It compiles and presents no errors. Several times I checked for spelling errors, etc.

If I delete the separator section (last pic), it works with one first token to the first place. So the error lies somewhere around the delimiter code.

source share