public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner input = new Scanner(System.in);
System.out.print("Enter password:");
String password = input.next();
if(detectionString(password)){
System.out.println("Valid Password");
}
else
System.out.println("Invalid Password");
}
public static boolean detectionString(String str){
if(str.length() < 8)
return false;
int count = 0;
for(int i = 0; i < str.length(); ++i){
if(!Character.isDigit(str.charAt(i)) && !Character.isLetter(str.charAt(i)))
return false;
if(Character.isDigit(str.charAt(i)))
++count;
}
if(count < 2)
return false;
return true;
}
java语言程序设计 第十版(基础篇)6.18
猜你喜欢
转载自blog.csdn.net/qq_41729287/article/details/83214375
今日推荐
周排行