关于java8(Stream)的一些用法

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

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

 

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

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

posted @ 2019-04-12 10:16  挖苦  阅读(513)  评论(0编辑  收藏  举报