[Java] 纯文本查看 复制代码 HashMap<Character,Integer> hashMap = new HashMap<>();
String text ="qqqwwwweeeee";
char[] charArray = text.toCharArray();
for (char c : charArray) {
if (hashMap.containsKey(c)) {
hashMap.put(c, hashMap.get(c)+1);
}else{
hashMap.put(c, 1);
}
}
System.out.println(hashMap); |