java 显示数组重复个数

List list = Arrays.asList("aa,xx,ss,xx,ss,e,w,a,aa".split(","));
Map map = new HashMap();

for (String s : list) {
Integer i = map.get(s);

if(i == null)
map.put(s, 1);
else
map.put(s, ++i);

}
System.out.println(map);

posted @ 2021-05-14 18:07  凌波漫步~  阅读(105)  评论(0编辑  收藏  举报