java - How to remove elements of one map from another map? -


hashmap<string, string> foo = new hashmap<string, string>(); hashmap<string, string> baar = new hashmap<string, string>(); 

how remove items found in baar foo?

you can try:

foo.keyset().removeall(baar.keyset()) 

changes map's keyset() reflected in map itself.

if want remove exact mappings (not based on keys), can use same approach entryset() instead:

foo.entryset().removeall(baar.entryset()); 

Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -