關於java8(Stream)的一些用法

若是要處理int[] 轉換成 List<Integer>這種形式的,能夠用下面這個方法:io

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

 

過濾去重能夠用下面這個方法:List

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

相關文章
相關標籤/搜索