我该如何做到这一点,如果用户名不正确,它不会要求输入密码,而是立即说用户名不正确?
import java.util.Scanner;
public class SecurityPasscode
{
public static void main(String[] args)
{
Scanner user_input = new Scanner(System. in );
System.out.println("Enter Username");
String username;
username = user_input.next();
if (username.equals("username"))
System.out.println("Enter Password");
String password;
password = user_input.next();
if (password.equals("password"))
System.out.println("Welcome back " + username + "!");
if (!"password".equals(password))
System.out.println("That password is incorrect.");
else if (!"username".equals(username))
System.out.println("That username is incorrect.");
}
}