回答編集履歴
2
型パラメータ仕様
answer
CHANGED
@@ -42,11 +42,11 @@
|
|
42
42
|
System.out.println(resultList);
|
43
43
|
}
|
44
44
|
|
45
|
-
private static List<Map<
|
45
|
+
private static <K,V> List<Map<K,V>> getResult(List<Map<K,V>> keyList, List<Map<K,V>> targetList) {
|
46
|
-
List<Map<
|
46
|
+
List<Map<K,V>> list = new ArrayList<>();
|
47
|
-
for(Map<
|
47
|
+
for(Map<K,V> target : targetList) {
|
48
|
-
Set<Map.Entry<
|
48
|
+
Set<Map.Entry<K,V>> targetEntrySet = target.entrySet();
|
49
|
-
for(Map<
|
49
|
+
for(Map<K,V> key : keyList) {
|
50
50
|
if(targetEntrySet.containsAll(key.entrySet())) {
|
51
51
|
list.add(target);
|
52
52
|
break;
|
1
リンク追加
answer
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
Map.entrySet() が返すのは Set ですので、 containsAll() が使えます。
|
1
|
+
[Map.entrySet()](https://docs.oracle.com/javase/jp/8/docs/api/java/util/Map.html#entrySet--) が返すのは `Set` ですので、 [Set.containsAll()](https://docs.oracle.com/javase/jp/8/docs/api/java/util/Set.html#containsAll-java.util.Collection-) が使えます。
|
2
2
|
```java
|
3
3
|
import java.util.*;
|
4
4
|
|