I have the following code:
System.out.println("");
System.out.println("Enter username:");
String userName = input.nextLine();
input.nextLine();
System.out.println("Enter password:");
String userPwd = input.nextLine();
System.out.println(userName.equals("Joe"));
System.out.println(userPwd.equals("password1"));
When I type in "Joe" and "password1" at the command prompt, only the second comparison returns "true". The first one returns "false". I have not found a solution. Should I be using a different library than Scanner? Thanks.
P.S. Is there a way to also get rid of the second input.nextLine();
?