有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

Java和Excel中的列表批处理给出了不同的结果

我需要批处理具有类似客户端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

我的代码有问题吗


共 (1) 个答案

  1. # 1 楼答案

    你的问题是:

    String id = c.getIdClient();
    List<Client> _clients = _batched.get(id);
    if(_clients == null){
        pois = new ArrayList<Client>();
        _batched.put(id, _clients);
    }
    _clients.add(c);
    

    在名为pois的变量中创建一个新数组,然后将变量_clients的内容放入_batched。输入pois的值会发生什么变化

    我不明白这怎么不是空指针异常