Read a Full Line
Completed
Read a whole line (it may contain spaces) and print Hello, LINE!
Input
One line.
Output
The greeting.
Example
Input
Ada Lovelace
Output
Hello, Ada Lovelace!
Editor
Java
Hints
next() reads one word; nextLine() reads the whole line.
Solution explanation
Use nextLine() when the input can contain spaces.
Show solution
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String name = sc.nextLine();
System.out.println("Hello, " + name + "!");
}
}