Practice9.3
来源:互联网 发布:淘宝卖家处理退货申请 编辑:程序博客网 时间:2024/06/06 03:38
//判断输入的字符串是否只含有字母和数字,并且至少八个字符,数字数目大于=2
import java.util.Scanner;
public class Practice9_3 {
public static void main(String[] args) {
Text();
}
//测试方法
public static void Text(){
Scanner input = new Scanner(System.in);
String string = input.nextLine();
if(isValid(string))
System.out.println("Valid Password");
else
System.out.println("Invalid Password");
}
//判断是否符合所有条件
public static boolean isValid(String st){
if(st.length()>=8 && only_NumLetter_Over2(st) )
return true;
else
return false;
}
//判断是否只有字母和数字,并数字数目>=2
public static boolean only_NumLetter_Over2(String st){
int count=0,flag=1;
for(int i=0 ; i<st.length() ; i++){
//调用Character中的isDigit和isLetter方法判断
if(!(Character.isDigit(st.charAt(i))) && !(Character.isLetter(st.charAt(i)))){
flag = 0;
break;
}
else if(Character.isDigit(st.charAt(i)))
count++;
}
if(flag==1 && count>=2)
return true;
else
return false;
}
}
- Practice9.3
- practice9.9
- 3
- 3
- 3
- 3
- 3
- (3)
- 3
- 3
- 3
- 3
- 3
- 3
- 3
- 3
- 3
- 3
- Http头 Range、Content-Range
- 操作系统之PV操作
- 状态(state)模式以及和策略(strategy)的比较
- PlotToDevice样例程序
- Tomcat设置默认启动项目及Java Web工程设置默认启动页面
- Practice9.3
- java解析Excel
- 禁止web.config重写
- nginx支持perl的fastcGI功能
- Android 事件派发流程图
- java单例模式的误导性
- utf_8与GB2312编码的转换
- 栈的数据结构定义及算法
- hibernate映射文件生成数据库脚本过程,sequence 设定初始值 以及自定义增量问题