public class Tset {
public static void main(String[] args) {
Scanner sc =new Scanner(System.in);
System.out.println("请输入QQ号码:");
String qq = sc.next();
boolean isOk = checkQQ(qq);
System.out.println("这个qq号是否正确"+isOk);
}
public static boolean checkQQ(String qq){
if(qq.length()<5 || qq.length() >12){
return false;
}
if(qq.charAt(0) =='0'){
return false;
}
for (int i = 0; i < qq.length(); i++) {
char c = qq.charAt(i);
if(c<'0'||c>'9'){
return false;
}
}
return true;
}
}
问题所在: 要实现这个需求首先要有好的思路一步步去实现
|
|