Using BufferedReader:
System.out.println("Please type your name and press Enter.");
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
try {
String name = reader.readLine();
System.out.println("Hello, " + name + "!");
} catch(I...