I am trying to check whether a map contains all contents of another map. For example, I have a mapA
which is a Map<String, List<String>>
and the elements are:
"1" -> ["a","b"]
"2" -> ["c","d"]
another mapB
which is also a Map<String, List<String>>
, the elements are:
"1" -> ["a"]
"2" -> ["c","d"],
I want to create a function compare(mapA, mapB)
which will return false in this case.
What is the best way to do this?
Inside your compare(mapA, mapB)
method, you can simply use:
return mapA.entrySet().containsAll(mapB.entrySet());
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With