技巧一://统计字符串s1的频率

    String s1 = in.nextLine();
//统计字符串s1的频率
        for (char c1 : s1.toCharArray()) {
            if (hashMap1.containsKey(c1)) {
                hashMap1.put(c1, hashMap1.get(c1) + 1);
            } else {
                hashMap1.put(c1, 1);
            }
        }
View Code

相关文章: