I have a Map<String, String> issueMap
with n values
and An ArrayList<String>
with m values, such that m is subset of n
I want to remove all these m keys from issueMap is there a direct API call for this
Thanks
You can remove the keys from the keySet
:
issueMap.keySet().removeAll(listOfKeysToRemove);
keySet
returns a Set
of the keys contained in the Map
, which is backed by the Map
. Therefore, changes to the Map
are reflected in the Set
and vice-versa.
Javadoc:
Set keySet()
Returns a Set view of the keys contained in this map. The set is backed by the map, so changes to the map are reflected in the set, and vice-versa. If the map is modified while an iteration over the set is in progress (except through the iterator's own remove operation), the results of the iteration are undefined. The set supports element removal, which removes the corresponding mapping from the map, via the Iterator.remove, Set.remove, removeAll, retainAll, and clear operations. It does not support the add or addAll operations.
Returns: a set view of the keys contained in this map
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