可以使用Java 8的Stream API和filter()方法来实现:

List<Long> result = newChargeSchemeIds.stream()
    .filter(id -> !oldChargeSchemeIds.contains(id))
    .collect(Collectors.toList());

首先,将newChargeSchemeIds转换为Stream对象。然后使用filter()方法过滤出不在oldChargeSchemeIds中的元素。最后使用collect()方法将过滤出的元素转换为List对象并返回。

有两个集合ListLong oldChargeSchemeIds和ListLong newChargeSchemeIds找出newChargeSchemeIds中不存在的元素

原文地址: https://www.cveoy.top/t/topic/gCFj 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录