这行程序假设测试一个字符串以确保它是 5 个字符并且以字符“u”开头。现在只是测试字符串是否是5个字符而不是测试的第二部分?
String UID;
do {
System.out.println("Enter the Student's UID in the form of u####");
UID = input.nextLine();
if (UID.length() != 5) {
System.out.println("INCORRECT INPUT");
}
} while (UID.length() != 5 && UID.charAt(0) != 'u');
return UID;
}