package com.test;
public class zifuchuanbianli {
public static void main(String[] args) {
String s ="ABCDEabcdef123456!@#$%%^";
int big = 0;
int small = 0;
int num = 0;
int other = 0;
for(int i=0;i<s.length();i++) {
//System.out.println(s.charAt(i));
char c = s.charAt(i); //通過索引拿取每一個字符
//判斷是否在此范圍之內
if(c >= 'A' && c <= 'Z') {
big++; //如果滿足大寫,計數器遞增
}else if(c >= 'a' && c <= 'z'){
small++;
}else if(c >= '0' && c <= '9') {
num++;
}else {
other++;
}
}
System.out.println("大寫字母"+big);
System.out.println("小寫字母"+small);
System.out.println("數字"+num);
System.out.println("其他"+other);
}
}