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;

  • 相关阅读:
    PHP返回XML与JSON数据
    Canvas学习-1
    PHP与cURL
    PHP调用SOAP Webservice
    Ubuntu查找文件是否安装
    API Centeric Web Application论文
    Git学习2
    An invalid character [32] was present in the Cookie value
    关于eclipse项目的x号报错的一些问题
    关于eclipse的项目前有感叹号和errors exist in required project相关问题
  • 原文地址:https://www.cnblogs.com/anrangesi/p/9430796.html
Copyright © 2011-2022 走看看