//计数器
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的重复值。