Let’s say I have a list containing some key-value pairs, and an array containing a number of value.
public boolean hasSameKey(List<Map.Entry<Key, Value>> list, Value ... values) {
return ?;
}
What I would like to check is that if all values in values have an entry in list with the same key.
Edit
To clarify, each key in the list may have keys with several values
From what I get from your question, I would first change your method signature a little to take
Map<Key, List<Value>>as first parameter.Then you can proceed like this: –
map.get(key)– Gets theList<Value>for that corresponding key.List#containsAllmethod checks whether all the elements in a particularcollectionis in that list or not.