public class Demo3 {
public static void main(String[] args) {
String s = "aaaHHHHssshjkHkhUkgft";
char[] arr = s.toCharArray();
int maxnum = 0;
int minnum = 0;
for (int i = 0; i < arr.length; i++) {
char cha = arr[i];
if (cha >= 'a' && cha <= 'z') {
minnum++;
} else if (cha >= 'A' && cha <= 'Z') {
maxnum++;
}
}
System.out.println("大写为:" + maxnum + "个" + "小写为:" + minnum + "个");
}
}
|
|