计算某字符串中大写字母、小写字母以及数字的个数
public class demo3 {
public static void main(String[] args) {
fun();
}
public static void fun() {
String s = "asdklf2234jLKJ";
byte [] s1=s.getBytes();
int a=0,b=0,c=0;
for (int i = 0; i < s1.length; i++) {
if (s1[i]>=97 && s1[i]<=122) {
a++;
}
if (s1[i]>=65&&s1[i]<=90) {
b++;
}
if (s1[i]>=48&&s1[i]<=57) {
c++;
}
}
System.out.println("大写字母的个数为"+b);
System.out.println("小写字母的个数为"+a);
System.out.println("数字的个数为"+c);
}
}