package com.qf.a.test; //3、输入一个字符串,其中包含中文字符、英文字符和数字字符,请统计和打印出各个字符的出现的次数。 public class Demo4 { public static void main(String[] args) { String ser = "dhadad1da1的大大大dada316541684313ada得好好打的的机器对机器的文件"; char[] t =ser.toCharArray(); int a = 0,b=0 , c=0 ; for (int i = 0; i <t.length ; i++) { if (t[i]>='0'&&'9'>=t[i]) { a++; }else if (t[i]>='a'&& t[i]<='z' || t[i]>='A'&& t[i]<='Z') { b++; }else { c++; } } System.out.println("数字有:"+a + "字母有:" + b + "文字有:"+c); } }