public static void main(String[] args) { List<GoodsInfor> list = new ArrayList<>(); List<GoodsInfor> list2 = new ArrayList<>(); GoodsInfor p = new GoodsInfor(); p.setGoodsId(1); p.setEachGoodsFare(1D); GoodsInfor p2 = new GoodsInfor(); p2.setGoodsId(2); p2.setEachGoodsFare(2D); GoodsInfor p3 = new GoodsInfor(); p3.setGoodsId(3); p3.setEachGoodsFare(3D); list.add(p); list.add(p2); list.add(p3); GoodsInfor p4 = new GoodsInfor(); p4.setGoodsId(1); p4.setEachGoodsFare(0D); GoodsInfor p5 = new GoodsInfor(); p5.setGoodsId(2); p5.setEachGoodsFare(0D); GoodsInfor p6 = new GoodsInfor(); p6.setGoodsId(3); p6.setEachGoodsFare(0D); GoodsInfor p7 = new GoodsInfor(); p7.setGoodsId(4); p7.setEachGoodsFare(0D); list2.add(p4); list2.add(p5); list2.add(p6); list2.add(p7); // list2.stream().flatMap(x -> list.stream() // .map(y -> {x.setEachGoodsFare(y.getEachGoodsFare()); // return x; // }) // ).collect(Collectors.toList()).forEach(m->System.out.println(m)); list2.stream().filter((x) -> list.stream().anyMatch((y)-> { if (x.getGoodsId() == y.getGoodsId()) { x.setEachGoodsFare(y.getEachGoodsFare()); return true; } return false; }) ).collect(Collectors.toList()).forEach(System.out::println); }