爲什麼這只是一直重複,即使當我輸入超過6個字符的長度?Java密碼程序循環永遠需要幫助
import java.util.Scanner;
class Password {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.println("Welcome please enter your username and password.");
System.out.print("Username >>");
input.nextLine();
enterPassword();
System.out.println("Successfully Logged In");
}
public static void enterPassword(){
String password;
Scanner input = new Scanner(System.in);
System.out.print("Password >>");
password = input.nextLine();
checkPasswordLength(password);
}
public static void checkPasswordLength(String password){
int length;
length = password.length();
while (length <6){
enterPassword();
}
checkPasswordLetter(password);
}
public static void checkPasswordLetter(String password){
System.out.println("More checking here to be added");
}
}
你不存儲你的用戶名是什麼? – 2013-07-02 03:29:19