jdk8将一个集合对象中的内容收集到另外一个集合对象中去

  • Post author:
  • Post category:其他




需求

将一个查询到的集合对象的结果集收集放在另外一个集合对象中去

//查询到的集合对象
List<IwmInfluenceWorkEntity> influences = iwmInfluenceWorkService.queryAll(params);
//封装过后的集合对象
List<InfluenceTypeDto> collect = influences.stream().map(a -> new InfluenceTypeDto(a.getWorkType(),
                a.getLicense(), null)).collect(Collectors.toList());
//遍历输出封装过后的集合对象
        collect.forEach(e -> {
            System.out.println("作业编号" + e.getLicenseCount() + "作业类型" + e.getWorkType());
        });



版权声明:本文为qq_25983579原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。