当前位置:网站首页>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
边栏推荐
- List announced | outstanding intellectual property service team in China in 2021
- Basic operation of binary tree
- js数组拼接的四种方法[通俗易懂]
- The correct way to set the bypass route
- 基于YOLOv5的口罩佩戴检测方法
- [monomer] recommended configuration of streaming information i-bpsv3 server
- 基于LSTM模型实现新闻分类
- 收到一封CTO来信,邀约面试机器学习工程师
- 使用闭包实现点击按钮切换 toggle
- PHP 读取ini或env类型配置
猜你喜欢
Yan Rong looks at how to formulate a multi cloud strategy in the era of hybrid cloud
Do you want to make up for the suspended examination in the first half of the year? Including ten examinations for supervision engineers, architects, etc
杰理之蓝牙耳机品控和生产技巧【篇】
pytest合集(2)— pytest运行方式
手动实现function isInstanceOf(child,Parent)
Pytest collection (2) - pytest operation mode
mysql 学习笔记-优化之SQL优化
MIT|256KB 内存下的设备上训练
基于K-means的用户画像聚类模型
AirServer2022最新版功能介绍及下载
随机推荐
NIO与传统IO的区别
使用闭包实现点击按钮切换 toggle
leetcode刷题:栈与队列01(用栈实现队列)
Classify boost libraries by function
BPR(贝叶斯个性化排序)
js如何获取集合对象中某元素列表
Introduction and download of the latest version of airserver2022
基于YOLOv5的口罩佩戴检测方法
分离字符串中的字母和数字并使得字母在前数组在后
手动实现function isInstanceOf(child,Parent)
MySQL数据库驱动(JDBC Driver)jar包下载
PHP 读取ini或env类型配置
burpsuite简单抓包教程[通俗易懂]
从20s优化到500ms,我用了这三招
PCB plug hole technology~
运放-滞回(迟滞)比较器全流程实战计算
Airserver mobile phone third-party screen projection computer software
idea中类中显示成员变量和方法
MySQL empties table data
Little p weekly Vol.11