You are looking for an operation removeAllfor map values.
public static void main(String[] args) {
Map<Integer, String> a = new HashMap<>();
a.put(1, "big");
a.put(2, "hello");
a.put(3, "world");
Map<Integer, String> b = new HashMap<>();
b.put(1,"hello");
b.put(2, "world");
a.values().removeAll(b.values());
System.out.println(a);
}
values() returns a representation of the values contained on this map:
Collection , . , .
, . :
, Iterator.remove, Collection.remove, removeAll, retainAll clear.
. , .
Map<Integer, String> newMap = new HashMap<>(a);
newMap.values().removeAll(b.values());
: !