标签:turn statistic chinese ring log 文字 ati dig main
public class StatisticZEN { public static void main(String[] args) { String str = "凛冬lindong12将至jiangzhi21"; statisticsChar(str); } private static HashMap<String, Integer> statisticsChar(String str) { int chineseCount = 0; int englishCount = 0; int digitCount = 0; for (int i = 0; i < str.length(); i++) { char c = str.charAt(i); if(c>=‘0‘ && c<=‘9‘) digitCount ++; else if((c>=‘a‘ && c<=‘z‘) || (c>=‘A‘ && c<=‘Z‘)) englishCount ++; else chineseCount ++; } HashMap<String, Integer> map = new HashMap<String, Integer>(); map.put("中文字符", chineseCount); map.put("英文字符", englishCount); map.put("数字字符", digitCount); return map; } }
标签:turn statistic chinese ring log 文字 ati dig main
原文地址:http://www.cnblogs.com/cuihw/p/7279404.html