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

2023-01-01 00:00:00 集合 中去 另外一个

需求

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

//查询到的集合对象
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());
        });
    原文作者:菜鸟笔记本
    原文地址: https://blog.csdn.net/qq_25983579/article/details/107024960
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。

相关文章