2 回答

TA貢獻(xiàn)1898條經(jīng)驗(yàn) 獲得超8個(gè)贊
if(Password.length() >= 8)并else if(Password.length() < 8)覆蓋所有可能的密碼長度,因此永遠(yuǎn)不會(huì)達(dá)到以下條件。
你應(yīng)該以一種不那么混亂的方式組織你的條件:
if (Password.length() < 8) {
System.out.println("Bruv youre asking to be hacked");
} else if (Password.length() >= 8 && Password.length() <= 10) {
System.out.println("Medium length of password");
} else if (Password.length() > 10 and Password.length() <= 13) {
System.out.println("Good password length");
} else if (Password.length() > 13 && Password.length() < 16) {
... // you might want to output something for passwords of length between 13 and 16
} else {
System.out.println("Great password length");
}
甚至更好
if (Password.length() < 8) {
System.out.println("Bruv youre asking to be hacked");
} else if (Password.length() <= 10) {
System.out.println("Medium length of password");
} else if (Password.length() <= 13) {
System.out.println("Good password length");
} else if (Password.length() < 16) {
... // you might want to output something for passwords of length between 13 and 16
} else {
System.out.println("Great password length");
}

TA貢獻(xiàn)1844條經(jīng)驗(yàn) 獲得超8個(gè)贊
嘗試使用:
if (Password.length() >= 8) {
if (Password.length() <= 10) {
System.out.println("Medium length of password");
} else if (Password.length() <= 13) {
System.out.println("Good password length");
} else if (Password.length() >= 16) {
System.out.println("Great password length");
}
} else if (Password.length() < 8) {
System.out.println("Bruv youre asking to be hacked");
}
添加回答
舉報(bào)