当前位置:网站首页>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
边栏推荐
- 《QTreeView+QAbstractItemModel自定义模型》:系列教程之三[通俗易懂]
- 最近公共祖先离线做法(tarjan)
- 函数基本学习之一
- 杰理之、产线装配环节【篇】
- LIS (longest ascending subsequence) problem that can be understood [easy to understand]
- [monomer] recommended configuration of streaming information i-bpsv3 server
- Microsoft, Columbia University | Godel: large scale pre training of goal oriented dialogue
- Why does blocprovider feel similar to provider?
- MySQL系列之事务日志Redo log学习笔记
- 4. 对象映射 - Mapping.Mapstercover
猜你喜欢
Introduction and download of the latest version of airserver2022
Pytest collection (2) - pytest operation mode
开环和闭环是什么意思?
【深度学习】利用深度学习监控女朋友的微信聊天?
BlocProvider 为什么感觉和 Provider 很相似?
东哥套现,大佬隐退?
二叉树的基本操作
List announced | outstanding intellectual property service team in China in 2021
pytest合集(2)— pytest运行方式
Why does blocprovider feel similar to provider?
随机推荐
PMP与NPDP之间的区别是什么?
微信小程序,连续播放多段视频。合成一个视频的样子,自定义视频进度条
[deep learning] use deep learning to monitor your girlfriend's wechat chat?
基础—io密集型计算和cpu密集型计算
Why does blocprovider feel similar to provider?
matlab遍历图像、字符串数组等基本操作
js如何获取集合对象中某元素列表
杰理之、产线装配环节【篇】
Separate the letters and numbers in the string so that the letters come first and the array comes last
PHP 读取ini或env类型配置
Go - exe corresponding to related dependency
Microsoft, Columbia University | Godel: large scale pre training of goal oriented dialogue
String类型转换BigDecimal、Date类型
Pytest collection (2) - pytest operation mode
【Opencv450】HOG+SVM 与Hog+cascade进行行人检测
BPR(贝叶斯个性化排序)
Icml2022 | interventional contrastive learning based on meta semantic regularization
Fundamentals - IO intensive computing and CPU intensive computing
杰理之蓝牙耳机品控和生产技巧【篇】
【商业终端仿真解决方案】上海道宁为您带来Georgia介绍、试用、教程