判断字符串是否为数字且至少包含一位字母

来源:互联网 发布:网络拓扑图图标 编辑:程序博客网 时间:2024/05/19 16:36

 //判断字符串是否为数字且至少包含一位字母
 private boolean isNumeric(String str){
  int a = 0;
  for (int i = 0 ; i < str.length(); i++){
     if (!Character.isDigit(str.charAt(i))){
      if((str.charAt(i) >='a' && str.charAt(i) <= 'z') ||(str.charAt(i) >= 'A' && str.charAt(i) <= 'Z')){
        a += 1;
        continue;
       }else{
        return false;
       }
      }else{
       continue;
      }
  }
  if(a>0) return true;
  else return false;
 }
0 0
原创粉丝点击