【发布时间】:2013-12-16 10:54:42
【问题描述】:
我需要批处理具有相似客户端 ID 的元素(字符串类型,但目前只有数值,如“12345”、“235134”等)
Map<String, List<Client>> _batched = new HashMap<String, List<Client>>();
for (Client c : _Clients)
{
String id = c.getIdClient();
List<Client> clients = _batched.get(id);
if(_clients == null){
clients = new ArrayList<Client>();
_batched.put(id, clients);
}
clients.add(c);
}
问题是,当我将此函数与 Excel (=SUM(IF(FREQUENCY(C2:C618,C2:C618)>0,1))) 的结果进行比较时,我会得到不同的结果,即 526 和 519。
我的代码有问题吗?
【问题讨论】:
-
不确定您是否只是在问题中输入了错误的代码,但您似乎在使用
_clients和clients来引用 for 循环内的同一个列表。
标签: java list hashmap batch-processing