0
点赞
收藏
分享

微信扫一扫

java 两个list 取出交集

君之言之 2022-08-02 阅读 85


List<Integer> accountIdListOne = new ArrayList<>();
accountIdListOne.add(1);
accountIdListOne.add(2);
accountIdListOne.add(3);

List<Integer> accountIdListTwo = new ArrayList<>();
accountIdListTwo.add(3);
accountIdListTwo.add(4);
accountIdListTwo.add(5);
accountIdListTwo.add(6);


List<Integer> accountIdList = accountIdListOne.stream().filter(accountIdListTwo::contains).collect(Collectors.toList());

System.out.println(accountIdList.toString());

 

举报

相关推荐

0 条评论