package com.beicai.zhengze;;
public class TestQQ {
public static void main(String[] args) {
/**
*对QQ号进行校验,
*要求:5-15位,第一位不能为0,不能有非法字符
*/
String QQ = "1214477012";
if( ! (QQ.length()< 5 || QQ.length() >15)){
if(! QQ.startsWith("0")){
char[] arr= QQ.toCharArray();
boolean flag = true;
for(int i =0;i< arr.length;i++){
if( arr[i]<'0' || arr[i] >'9'){
flag =false;
break;
}
}
if(flag)
System.out.println("QQ号:"+QQ);
else
System.out.println("非法QQ号!");
}
else{
System.out.println("QQ号不能以0开头!");
}
}
else {
System.out.println("QQ号超度不符合要求!");
}
}
}
public class TestQQ {
public static void main(String[] args) {
/**
*对QQ号进行校验,
*要求:5-15位,第一位不能为0,不能有非法字符
*/
String QQ = "1214477012";
if( ! (QQ.length()< 5 || QQ.length() >15)){
if(! QQ.startsWith("0")){
char[] arr= QQ.toCharArray();
boolean flag = true;
for(int i =0;i< arr.length;i++){
if( arr[i]<'0' || arr[i] >'9'){
flag =false;
break;
}
}
if(flag)
System.out.println("QQ号:"+QQ);
else
System.out.println("非法QQ号!");
}
else{
System.out.println("QQ号不能以0开头!");
}
}
else {
System.out.println("QQ号超度不符合要求!");
}
}
}