zoukankan      html  css  js  c++  java
  • HashMap与LinkedHashMap的区别

    /**
             * remark:
             * HashMap与LinkedHashMap的区别
             * 这里必须使用LinkedHashMap:
             * 原因是LinkedHashMap保存了记录的插入顺序,
             * 在用Iterator遍历LinkedHashMap时,
             * 先得到的记录肯定是先插入的
             * 如果这里使用了HashMap则在resultList.addAll(summary.values())
             * 之后写到Excel中时顺序就会乱掉,
             * 而使用LinkedHashMap就会保持与reportTtlDataList循环记录的顺序一致
             */
            Map summary = new LinkedHashMap();
            summary.put("", new AribaReceiptInvoicePojo());
            AribaReceiptInvoicePojo titleChange = new AribaReceiptInvoicePojo();
            titleChange.setEcaGLAccount("差异汇总");
            titleChange.setEcaGRQty("Y");
            titleChange.setEcaActAmt("N");
            summary.put("title", titleChange);

            if(reportTtlDataList.size()>0){
                for (int i = 0; i < reportTtlDataList.size(); i++) {
                    Object[] obj = reportTtlDataList.get(i);
                    AribaReceiptInvoicePojo c = new AribaReceiptInvoicePojo();
                    c.setEcaGLAccount(obj[0].toString());
                    c.setEcaGRQty(obj[1].toString());
                    c.setEcaActAmt(obj[2].toString());
                    summary.put("c" + i, c);
                }
            }
            
            resultList.addAll(summary.values());
                
            return resultList;

  • 相关阅读:
    注册表修改 Devenv 默认启动 Visual Studio 版本
    python——高级特性(2)
    python——高级特性
    Hibernate—部分
    Filter—过滤器和拦截器的区别
    POST—常见的4种提交方式
    POST—GET—两种提交方式的区别
    JSON—fastJSON
    协程小示例
    协程基础
  • 原文地址:https://www.cnblogs.com/anrangesi/p/9430796.html
Copyright © 2011-2022 走看看