I have this code
System.out.println("Enter surname to search for:");
String choice2;
choice2= sc.nextLine();
In my opinion, this should work, but for some reason the program is not pausing to wait for the user to enter surname, the next line of code is executed exactly after it. Is something wrong with this code please?
This code is correct , and already wait until the user enter the name ,
but this code will not pausing in case of you press the Enter key before you enter the name because you use sc.nextLine() , but sc.next() will wait you until you enter the text