统计数组中重复元素个数
生活随笔
收集整理的這篇文章主要介紹了
统计数组中重复元素个数
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
/*** 循環統計數組或集合中的重復元素個數* @param args*/public static void main(String[] args) {Map<String, Integer> map = new HashMap<String, Integer>();String[] ss = {"白","黑","綠","白"};for (int i = 0; i < ss.length; i++) {if (map.get(ss[i]) != null) {Integer num = (Integer) map.get(ss[i]);num++;map.put(ss[i], num);} else {map.put(ss[i], 1);}}System.out.println(map);}
?
轉載于:https://www.cnblogs.com/mengzw/p/3753248.html
總結
以上是生活随笔為你收集整理的统计数组中重复元素个数的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 将Array、Dictionary等集合
- 下一篇: [欧拉函数] Bzoj P2186 沙拉