package lianxi;
public class Lian {
public static void main(String[] args) {
String s = "sjGhf1Rd3iD4g";
int a = 0;
int b = 0;
int c = 0;
for (int i = 0; i < s.length(); i++) {
if (s.charAt(i) >= '0' && s.charAt(i) <= '9') {
a++;
}
if(s.charAt(i) >= 'a' && s.charAt(i) <= 'z'){
b++;
}
if(s.charAt(i) >= 'A' && s.charAt(i) <= 'Z'){
c++;
}
}System.out.println("数字出现的次数是:"+ a +",小写字母出现的次数是:"+b+",大写字母出现的次数是:"+c);
}
} |
|