做天津杰超项目中赛事活动作品审核中写的一段代码:

 //获取全部作品
ActivityProductionQueryCommond productionQueryCommond=new ActivityProductionQueryCommond();
productionQueryCommond.setSearchProductionWorksId(worksValidCommond.getProductionWorksId());
List<ActivityProductionValidCommond> productionValidCommonds=(List<ActivityProductionValidCommond>) this.activityProductionService
    .findAllList(productionQueryCommond);
//循环分组
Map<String, List<ActivityProductionValidCommond>> proHashMap=new HashMap<String, List<ActivityProductionValidCommond>>();
for (ActivityProductionValidCommond production : productionValidCommonds) {
if(proHashMap.containsKey(production.getProductionGroupId())) {
proHashMap.get(production.getProductionGroupId()).add(production);
}else {
List<ActivityProductionValidCommond> proList=new ArrayList<ActivityProductionValidCommond>();
proList.add(production);
proHashMap.put(production.getProductionGroupId(), proList);
}
}
List<String> keyList=new ArrayList<String>(proHashMap.keySet());
Collections.sort(keyList);//key排序 空在最上面
Map<String, List<ActivityProductionValidCommond>> proLinkedMap=new LinkedHashMap<String, List<ActivityProductionValidCommond>>();
//生成有序map
for (String key : keyList) {
if(PropertyUtil.objectNotEmpty(key)) {
ProductionGroupValidCommond group=this.productionGroupService.find(key);
key=group.getProductionGroupName();
}else {
key="未分组";
}
proLinkedMap.put(key, proHashMap.get(key));
}

写的不好。请大神们指正。我改。

ArrayList转成HashMap再转成LinkedHashMap 自己的解决方案的更多相关文章

  1. Android——ArrayList 、LinkList、List 区别 & 迭代器iterator的使用 & HashMap、Hashtable、LinkedHashMap、TreeMap

     ArrayList .LinkList.List 区别 & 迭代器iterator的使用 & HashMap.Hashtable.LinkedHashMap.TreeMap 一.几个 ...

  2. jQuery操作列表数据转成Json再输出为html dom树

    jQuery 把列表数据转成Json再输出为如下 dom树 <div id="menu" class="lv1"> <ul class=&qu ...

  3. C#部分---arraylist集合、arraylist集合中的object数据转换成int类string类等;间隔时间的表示方法;

    ArrayList和Array的区别: 相同点:1.两者都实现了IList.ICollection.IEnumerable接口:       2.两者都可以使用证书索引访问集合中的元素,包括读取和赋值 ...

  4. TerraGate SFS 4.5 版本 发布矢量数据使用的Cache数据如何再返回成shapefile文件

    TerraGate SFS 4.5 版本 发布矢量数据使用的Cache数据如何再返回成shapefile文件? 两年前帮一个朋友解决过这个问题: 如果原来用4.5版本的时候,在网络环境下,为了提升调用 ...

  5. json中把非json格式的字符串转换成json对象再转换成json字符串

    JSON.toJson(str).toString()假如key和value都是整数的时候,先转换成jsonObject对象,再转换成json字符串

  6. json 串转成 java 对象再拼接成前台 html 元素

    获取商品参数 json 串,转成 java 对象,再拼接成前台 html 的Service方法 @Override public String getItemParam(Long itemId) { ...

  7. laravel 将数组转化成字符串 再把字符串转化成数组

    这是在给阮少翔改代码的时候用的方法, 开始的数据用explored转化成数组不是想要的结果, 我就自己写了一个方法把有用的信息提取出来拼接成一个字符串, 再用explored将字符串转化成数组.   ...

  8. HashMap、HashTable、LinkedHashMap和TreeMap用法和区别

    Java为数据结构中的映射定义了一个接口java.util.Map,它有四个实现类,分别是HashMap.HashTable.LinkedHashMap和TreeMap.本节实例主要介绍这4中实例的用 ...

  9. HashMap、Hashtable、LinkedHashMap、TreeMap、ConcurrentHashMap的区别

    Map是Java最常用的集合类之一.它有很多实现类,我总结了几种常用的Map实现类,如下图所示.本篇文章重点总结几个Map实现类的特点和区别: 特点总结: 实现类 HashMap LinkedHash ...

随机推荐

  1. IOS框架和服务

    在iOS中框架是一个目录,包含了共享资源库,用于访问该资源库中储存的代码的头文件,以及图像.声音文件等其他资源.共享资源库定义应用程序可以调用的函数和方法. iOS为应用程序开发提供了许多可使用的框架 ...

  2. linux环境下安装tomcat并配置tomcat日志分割

    1.直接解压apache-tomcat-7.0.69.tar.gz 存放在/home目录下 根据需要自定义tomcat名称 mv apache-tomcat-7.0.69 Tomcat7 2.解压cr ...

  3. 初识reactJs 相关

           喽了一眼阮一峰老师的react文章,感觉写的挺棒,这篇只是按照自己思路屡一遍,纯属自学笔记,不承担社会暴乱责任.前几天,打算学vuejs,师兄给了一句话的点播,感觉很醍醐灌顶.总结下,所 ...

  4. 《C++primer》v5 第8章 IO库 读书笔记 习题答案

    8.1.8.2 这一章不咋会啊.. istream &read(istream &is) { int a; auto old_state=is.rdstate(); is.clear( ...

  5. MongoDB学习

    最近在学习,参考一线码农的教程 http://www.cnblogs.com/huangxincheng/category/355399.html

  6. popen使用不当引起产生僵尸进程

    FILE * popen(const char * command, const char * type)popen函数会通过fork产生子进程,然后从子进程中调用/bin/sh -c执行参数comm ...

  7. spring注解说明之Spring2.5 注解介绍(3.0通用)

    spring注解说明之Spring2.5 注解介绍(3.0通用) 注册注解处理器 方式一:bean <bean class="org.springframework.beans.fac ...

  8. Github上有趣的资料 | JS

    留着,以后用得着,原文地址:http://www.jianshu.com/p/7c9aa9508641 collection AlloyImage 基于HTML5的专业级图像处理开源引擎.An ima ...

  9. Java并发编程学习笔记(三)——对象的组合

    重要概念: 1.在设计线程安全类的过程中,需要包含以下三个基本要素: (1)找出构成对象状态的所有变量. (2)找出约束状态变量的不变性条件. (3)建立对象状态的并发访问管理策略. 2.

  10. Android Studio Problem : failed to find style 'textviewstyle' in current theme 解决方法

    新建一个空白的MainActivity时Preview就出现一个错误: failed to find style 'textviewstyle' in current theme 开始在国内的博客平台 ...