Solution
String[] strs = {"apple",...};
Map<String, Integer> map = new HashMap<String, Integer>();
for (String str : strs) {
if (map.containsKey(str)) {
Integer integer = map.get(str);
integer++;
map.put(str, integer);
} else {
map.put(str, 1);
}
}
for (Map.Entry<String, Integer> me : map.entrySet()) {
String strKey = me.getKey();
Integer iCount = me.getValue();
System.out.println(strKey + "出现了" + iCount + "次");
}
FEATURED TAGS
algorithm
algorithm-problem
architectural-pattern
architecture
aws
c#
cache-system
codis
concurrent-control
data-format
data-structure
database
debug
design
design-pattern
distributed-system
django
docker
engineering
engingeering
freebsd
git
golang
grafana
hackintosh
hardware
hexo
http
hugo
ios
iot
java
java-ee
javascript
kafka
kubernetes
linux
lock
macos
markdown
microservices
mysql
nas
network
network-programming
nginx
node.js
npm
oop
openwrt
operating-system
operating-systems
padavan
performance
programming
prometheus
protobuf
python
redis
router
security
shell
software-testing
spring
sql
truenas
ubuntu
vmware
vpn
windows
wmware
wordpress
zookeeper