0

Program not Waiting for Input

Hey y'all I need your assitance. Thx in advance. After displaying "Enter name:", I expect to the program to wait for user input, but it doesn't and instead, displays "Enter email:", after which it waits user input. What I mean is that after displaying the first string, it doesn't wait for input before displaying the second string; it is after the second string is displayed that it waits for user input. Below is the code: //I had earlier instantiated scanner object being used here System.out.println("Enter name:"); String name = String.valueOf(s.nextLine());// System.out.println("Enter email:"); String email = String.valueOf(s.nextLine()); System.out.println("Enter address:");

13th May 2022, 1:02 PM
Ayomisesebere
Ayomisesebere - avatar
2 Respuestas
0
I am sorry but maybe you have a typo in your question cause it sounds like it's doing exactly what you want it to do. You said "After displaying [string] I expect it to wait for user input" and then after say "It displays [string] after which it waits for user input". Do you mean the say something else?
13th May 2022, 1:05 PM
Justice
Justice - avatar
0
Can you share full code? It works as expected I think. . And You don't need to convert to string as nextLine() accept input in string form already....
13th May 2022, 2:01 PM
Jayakrishna 🇮🇳