ContactUs :

Please send your Questions & Answers or Feedback to "mohan@javabook.org"

Why HashCode() and equals() ?

while working with the HashMap, we can set the values to the HashMap and we can get the values from the HashMap. When we set the user defined data types to the hashMap while retrieving we cannot get the same values from the hashMap. Because setting object address and the retrieving object address is different. To resolve this problem we need to override the hashCode() and the equals(). But this problem cannot occur when we set the String as the hashMap key because  the String class already override those two methods.
Related Posts Plugin for WordPress, Blogger...
Flag Counter