可以使用 Java Stream 中的 anyMatch() 方法来判断 List<Map<String, String>> 中的 Map 的 'dept_parent_id' 是否等于 'C1000'。

代码示例:

List<Map<String, String>> list = new ArrayList<>();

// 添加 Map 数据到 List
Map<String, String> map1 = new HashMap<>();
map1.put('dept_parent_id', 'C1000');
list.add(map1);

Map<String, String> map2 = new HashMap<>();
map2.put('dept_parent_id', 'C2000');
list.add(map2);

// 使用 Stream 判断是否存在 'dept_parent_id' 等于 'C1000'
boolean exists = list.stream().anyMatch(map -> map.get('dept_parent_id').equals('C1000'));

System.out.println(exists); // 输出:true

在上面的示例中,我们创建了一个 List<Map<String, String>>,并添加了两个 Map 对象到 List 中。然后使用 Stream 的 anyMatch() 方法来判断是否存在 'dept_parent_id' 等于 'C1000' 的 Map 对象。最后输出结果为 true,表示存在符合条件的 Map 对象。


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

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