public class Demo22 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("请输入一个字符串");
String str = sc.next();
int small = 0;
int big = 0;
int count = 0;
for (int i = 0; i < str.length(); i++) {
char c = str.charAt(i);
if(c >= 'a'&&c <= 'z'){
small++;
}
if(c >= 'A'&&c <= 'Z'){
big++;
}
if(c >= '0'&&c <= '9'){
count++;
}
}
System.out.println("小写个数:" + small);
System.out.println("大写个数:" + big);
System.out.println("数字个数:" + count);
}
}
01-19
1万+
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交