day25-3获取指定字符串中,大写字母、小写字母、数字的个数

  • Post author:
  • Post category:其他


package zuoye2;

public class zuoye1 {


public static void main(String[] args) {


a();

}

public static void a(){


String a1=”asdaa12112ADSJADY”;

byte[] b=a1.getBytes();

int q=0;

int q1=0;

int q2=0;

for(int i=0;i<b.length;i++){


int c=b[i];

if(97<=c&&c<=122){


q++;

}

if(65<=c&&c<=90){


q1++;

}

if(48<=c&&c<=57){


q2++;

}

}

System.out.println(“内容为”+a1);

System.out.println(“大写个数”+q);

System.out.println(“小写个数”+q1);

System.out.println(“数字个数”+q2);

}

}

转载于:https://www.cnblogs.com/hfew/p/10561272.html