首页 > 技术文章 > 关于java8(Stream)的一些用法

PrayzzZ 2019-04-12 10:16 原文

如果要处理int[] 转换成 List<Integer>这种形式的,可以用下面这个方法:

List<Integer> orgIds = Arrays.stream(reqVo.organizationIds).boxed().collect(Collectors.toList());

 

过滤去重可以用下面这个方法:

List<Integer> newOrgIds =orgIds .stream().distinct().collect(Collectors.toList());

推荐阅读