/*** 判断一个字符串大写小写,和数字出现的次数*/ public class Demo4 {public static void main(String[] args) {String str = "A1baC51-*/";//将字符串转为字符数组;char[] chars = str.toCharArray();int bigCount = 0, smallCount = 0, numCount = 0, count = 0;for (char c : chars) {if (c >= 'a' && c <= 'z') {//统计大写字母出现的次数bigCount++;} else if (c >= 'A' && c <= 'Z') {//统计小写字母出现的次数smallCount++;} else if (c >= '0' && c <= '9') {//统计数字出现的次数numCount++;} else {count++;}}System.out.println("字 符 串的总长度为: " + str.length());System.out.println("大写字母出现的次数: " + bigCount);System.out.println("小写字母出现的次数: " + smallCount);System.out.println("数 字 出 现 的次数: " + numCount);System.out.println("非法字符出现的次数: " + count);} }