comparing the keysets of two hashmaps

hi ..

Please let me know if i use the following :

(hashmap1.keyset().equals(hashmap2.keyset())) return true;

would it return true always ...the keysets always being Strings in the case...i mean would it always check if all the keys are present in both the keysets..?

thanks.

[306 byte] By [@developer@a] at [2007-11-27 3:04:36]
# 1
a quick look at the source code for KeySet, which HashMap.keySet returns, shows that it extends AbstractSet, whose equals method works as you suspect. you could always write a quick test to prove it, though!
georgemca at 2007-7-12 3:49:16 > top of Java-index,Java Essentials,New To Java...
# 2
Better yet, a look a the documentation will tell you that java.util.Set specifies equals() to behave in a specific fashion, compatible with your requirements.
Herko_ter_Horsta at 2007-7-12 3:49:16 > top of Java-index,Java Essentials,New To Java...