Java Tricky Program 19 - equals and hashCode method overriding

preview_player
Показать описание
What happens when we don't override equals and hashCode method in java classes effectively. A simple program showing mistake that can pass our eyes in first look but can be easily caught if we always use Override annotation and follow the contract of equals and hashCode methods.
Рекомендации по теме
Комментарии
Автор

If you did not tell that I would not have ever known it - as simple as that.Thanks a lot.

mistery
Автор

Why we need to override hashcode ? If we are not overide hashcode method what will happen?

ashokreddybadam
Автор

Sir why some random multiplication... can i use an even number

HungryBirdStephenHaokip
Автор

In the hashcode method... can i put any other number... instead of 31

HungryBirdStephenHaokip
Автор

In general we can say one thing is that, Two objects are said to be equal only when their hashcode returns same value.

arunkumarmohapatra