Error with the Scanner, unknown source
I am creating a greeting program in Java: import java.util.Scanner; public class greeting { public static void main(String[] args){ System.out.println("What is your first name?"); Scanner one = new Scanner(System.in); String firstname = one.next(); System.out.println("What is your last name?"); Scanner two = new Scanner(System.in); String lastname = two.next(); System.out.println("Hello, " + firstname + " " + lastname + "!"); } } When I run the program in the Java Code Playground, I get the following error message: Exception in thread "main" java.util.NoSuchElementException at java.util.Scanner.throwFor(Unknown Source) at java.util.Scanner.next(Unknown Source) at personalgreeting.main(personalgreeting.java:12) What is wrong with the code? Thanks