How would you test Scanner input in Java?

So I am new to Replit. I am trying to make a test that test input from the keyboard and then a final print statement. However, my test keeps getting stuck at the first Print statement I ask. Even though my output is correct. Just curious on how to go about testing Scanner input?

So like:

System.out.println("What is your name?");
String name = input.nextLine();

How do I get it to recognize both the statement and the return?

Any help is appreciated. Thanks in advance!

You are viewing a single comment. View All


Thank you for your response. I understand how Scanner works but I just can't figure it out if someone enters different names. So I just told the students to input a certain name. If you know how I can test it with different inputs that would be helpful!