当前位置:网站首页>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
边栏推荐
- 旁路由设置的正确方式
- PHP reflective XSS, reflective XSS test and repair
- 中通笔试题:翻转字符串,例如abcd打印出dcba
- BPR(贝叶斯个性化排序)
- JS how to get a list of elements in a collection object
- Using closures to switch toggle by clicking a button
- 业务可视化-让你的流程图'Run'起来
- Why does blocprovider feel similar to provider?
- I received a letter from CTO inviting me to interview machine learning engineer
- 辅音和声母的区别?(声母与辅音的区别)
猜你喜欢

杰理之烧录上层版物料需要【篇】

Manually implement function isinstanceof (child, parent)
![[noip2013] building block competition [noip2018] road laying greed / difference](/img/d1/a56231cd4eb3cc1d91d8a55048ccfe.png)
[noip2013] building block competition [noip2018] road laying greed / difference

按照功能对Boost库进行分类

手动实现function isInstanceOf(child,Parent)

Getting started with the lockust series

One of the basic learning of function

Little p weekly Vol.11

基于K-means的用户画像聚类模型

News classification based on LSTM model
随机推荐
MIT|256KB 内存下的设备上训练
从20s优化到500ms,我用了这三招
新版图解网络PDF即将发布
Accelera Systems Initiative是一个独立的非营利组织
UVM教程
月入1W+的自媒体达人都会用到的运营工具
Basic operation of binary tree
人才近悦远来,望城区夯实“强省会”智力底座
Manually implement function isinstanceof (child, parent)
开环和闭环是什么意思?
功利点没啥!
A debugging to understand the slot mechanism of redis cluster
基于LSTM模型实现新闻分类
Separate the letters and numbers in the string so that the letters come first and the array comes last
【单体】流辰信息I-BPSv3服务器推荐配置
String type conversion BigDecimal, date type
按照功能对Boost库进行分类
K-means based user portrait clustering model
辅音和声母的区别?(声母与辅音的区别)
php反射型xss,反射型XSS测试及修复