当前位置:网站首页>Count the number of each character in the character
Count the number of each character in the character
2022-07-01 22:11:00 【Full stack programmer webmaster】
Hello everyone , I meet you again , I'm your friend, Quan Jun .
Count the number of each character in the character :
import java.util.HashMap;
public class Count the number of each character in the character {
public static void main(String[] args) {
String str = "aaabbbbgbbccc";
char[] ch = str.toCharArray();
HashMap<Character,Integer> hm = new HashMap<>();
for (char c : ch) {
// If it contains this character, it is the number +1
if (hm.containsKey(c)) {
hm.put(c,hm.get(c) + 1);
}else {
hm.put(c, 1);
}
}
System.out.println(hm);
}
}Publisher : Full stack programmer stack length , Reprint please indicate the source :https://javaforall.cn/147189.html Link to the original text :https://javaforall.cn
边栏推荐
猜你喜欢

pytest合集(2)— pytest运行方式

JS how to get a list of elements in a collection object
![[live broadcast review] the first 8 live broadcasts of battle code Pioneer have come to a perfect end. Please look forward to the next one!](/img/27/4bd0de716f5cb360d54f140dc8e9c1.png)
[live broadcast review] the first 8 live broadcasts of battle code Pioneer have come to a perfect end. Please look forward to the next one!

"The silk road is in its youth and looks at Fujian" is in the hot collection of works in the Fujian foreign youth short video competition

Spark面试题

函数基本学习之一

小 P 周刊 Vol.11

Manually implement function isinstanceof (child, parent)

Kuberntes云原生实战一 高可用部署架构

“丝路正青春 风采看福建”在闽外籍青年短视频大赛火热征集作品中
随机推荐
leetcode刷题:栈与队列02(用队列实现栈)
业务可视化-让你的流程图'Run'起来
pytest合集(2)— pytest运行方式
杰理之、产线装配环节【篇】
idea中类中显示成员变量和方法
The difference between NiO and traditional IO
C中main函数的几种写法
杰理之蓝牙耳机品控和生产技巧【篇】
功利点没啥!
EMC-电路保护器件-防浪涌及冲击电流用
分离字符串中的字母和数字并使得字母在前数组在后
I received a letter from CTO inviting me to interview machine learning engineer
Difference and use between require and import
工控设备安全加密的意义和措施
burpsuite简单抓包教程[通俗易懂]
A debugging to understand the slot mechanism of redis cluster
基于LSTM模型实现新闻分类
ICML2022 | 基于元语义正则化的介入性对比学习
ngnix基础知识
想请教一下,券商选哪个比较好尼?本人小白不懂,现在网上开户安全么?