控制台输入字符串,统计出大小字母,数字字符的个数

 public static void main(String[] args) {
        // 在控制台输入字符串,统计出大写的字符的个数,小写的字符个数,数字类型的字符个数,以及其余字符的个数
        Scanner sc = new Scanner(System.in);  //控制台输入字符串
        int big = 0;   //初始化字符个数
        int small = 0;
        int num = 0;
        int other = 0;

        System.out.println("请输入一串字符串");
        String str = sc.next();

        for (int i = 0; i < str.length(); i++) {
            if (str.charAt(i) >= 65 && str.charAt(i) <= 90) {
                big++;
            } else if (str.charAt(i) >= 97 && str.charAt(i) <= 122) {
                small++;
            } else if (str.charAt(i) >= 48 && str.charAt(i) <= 57) {
                num++;
            } else {
                other++;
            }
        }
        System.out.println("大写字母有:" + big + "个");
        System.out.println("小写字母有:" + small + "个");
        System.out.println("数字有:" + num + "个");
        System.out.println("其余字符有:" + other + "个");
    }