import java.util.Scanner;
public class Test {
public static void nameInput() {
Scanner sc = new Scanner(System.in);
System.out.println("What is your name?");
String name = sc.next();
sc.close();
}
public static void main(String args[]) {
nameInput();
System.out.print(name);
}
import java.util.Scanner;
public class Test {
private static String name;
public static void nameInput() {
try (Scanner sc = new Scanner(System.in)) {
System.out.print("What is your name? ");
Test.name = sc.next();
}
}
public static void main(String args[]) {
Test.nameInput();
System.out.println(Test.name);
}
}