【发布时间】:2021-09-14 12:00:43
【问题描述】:
我有一个HashMap:
HashMap<Integer,Integer> hashMap = new HashMap<Integer,Integer>();
还有一个Set 的Sets:
Set<Set<Integer>> set = Set.of(Set.of(0, 1, 2), Set.of(3, 4, 5));
我想检查 HashMap 的 3 个键是否包含 Set 的 3 个元素,如果是,请检查值是否相等。
例如:
hashMap.put(0,1);
hashMap.put(1,1);
hashMap.put(2,1);
return true;
hashMap.put(4,2);
hashMap.put(5,2);
hashMap.put(12,2);
return false;
stream() 是否有可能的解决方案?
【问题讨论】:
-
所以这是this的反面?
-
看起来他在一些编程练习中寻求解决方案。
标签: java dictionary hashmap set java-stream