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

 //获取全部作品
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. angular初步认识一

    最近比较流行MVC前端框架开发,最近研究了一个框架AngularJS框架 不说那么多,先上例子,我是个代码控 <!DOCTYPE html> <html lang="en& ...

  2. DotSpatial 创建面状要素——含空洞

    private void toolStripButton23_Click(object sender, EventArgs e) { //选择图层 FeatureSet fs = null; fs = ...

  3. Cordova+ionic 开发hybird App --- 开发环境搭建

    Cordova 开发hybird App 开发环境搭建 一.一些基础概念: Ant : 简单说来可以这么理解,如果你用记事本写JAVA程序,然后在cmd里输入javac命令编译它,但是有一天你发现每次 ...

  4. iOS开发(OC)中的命名规范

    开小差:最近发现自己有一个经验主义的毛病,不太容易接受新的知识,这对从事技术研发的人来说不太合理,需要改之. 正文:通过读写大量代码我有自己的一套编程思路和习惯,自认为自己的编码习惯还是不错的,代码结 ...

  5. 数据类型int、bigint、smallint 和 tinyint范围

      bigint 从 -2^63 (-9223372036854775808) 到 2^63-1 (9223372036854775807) 的整型数据(所有数字).存储大小为 8 个字节. int ...

  6. shape的简单用法

    shap节点-----------------------------------定义shape的值,必须是下面的之一:"rectangle" 矩阵,这也是默认的shape&quo ...

  7. android开发虚拟机不能正常启动

    点击 window---perspective---DDMS---查看设备状态, 如果显示没有可用设备,则在AVD manager中重 启即可, 若列表中有设备,但显示offline  可采用一下方式 ...

  8. Xcode清除缓存、清理多余证书

    Xcode清除缓存.清理多余证书 1.删除Xcode中多余的证书provisioning profile 手动删除: Xcode6 provisioning profile path: ~/Libra ...

  9. Arraylist<E>

    ArrayList 应该是大部分人接触JCF之后, 第一个熟悉和使用的类.它的特点主要有一下几个: 1. 基于数组 public ArrayList(int initialCapacity) { if ...

  10. 修改mozilla firefox的设置

    修改firefox的user agent 浏览器里输入about:config 修改general.useragent.override