You cannot do that because the constructor for StringTokenizer() requires an argument of type java.lang.String
, but System.in is of type java.io.InputStream
.
A better way of converting user input to a String would be to use a Scanner
Scanner sc = new Scanner(System.in);
System.out.println("Enter name: ");
String name = sc.nextLine();
System.out.println("Enter age: ");
String age = sc.nextLine();
System.out.println(name + " is " + age + "years old");