dictionary - Intersection of java.util.Map -


is there method in java.util.map or util perform intersection on 2 maps? (to intersect 2 maps "keys")

i not able find any. can implement own intersection logic, hoping there operation in 1 of java.util.* classes this.

how about:

map map1 = ...; map map2 = ...; map result = new ...(map1); result.keyset().retainall(map2.keyset()); 

or:

map map1 = ...; map map2 = ...; set result = new ...(map1.keyset()); result.retainall(map2.keyset()); 

Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -