简单高性能计数器

        //计数器
        HashMap<String, Integer> count = new HashMap<String, Integer>();
        for (HouseTemp htemp : hdata) {
            String currkey = htemp.getTaizhang();
            if (count.containsKey(currkey)) {
                int oldValue = count.get(currkey);
                count.put(currkey, oldValue + 1);
            } else {
                count.put(currkey, 1);
            }
        }    

  直接遍历集合 可直接根据自定义key自动获取该key的重复值。

posted @ 2017-07-11 10:38  蓝色枫梦  阅读(211)  评论(0编辑  收藏  举报