jdk8新特性 list集合取交集

list集合取交集 jdk8新特性

 List result = new ArrayList<>();
 List goodsthirdIdList = new ArrayList<>();
 if(result.isEmpty()) {
       result = goodsthirdIdList;
 } else {  
       result = result.stream()
                        .filter(t->goodsthirdIdList.stream()
                        .anyMatch(t2->t2.getGoodsId()==t.getGoodsId()))
                        .collect(Collectors.toList());
 }

你可能感兴趣的:(jdk8新特性 list集合取交集)