I have the following code:
String username="administrator", iusername="", password="password", ipassword="";
System.out.println("Please login to the system");
System.out.print("\nusername:\t");
iusername = scan.nextLine();
System.out.print("\npassword:\t");
ipassword = scan.nextLine();
i want user enter data for two variable (iusername and ipassword) but i only can enter data for ipassword, because it skip
iusername = scan.nextLine();
below is the sample of output from IDE
username: username:
password: BUILD STOPPED (total time: 12 seconds)
it skip my username and go to password
scanandscan2? It sounds like you've created two separateScannerinstances... why? (And why are you initializing your variables and then immediately assigning new values?)scanandscan2. What's the difference?scanandscan2is because i cannot enter the username variable data and it jump to the password variable @JonSkeet and @jeroenVannevel