Equals and Hashcode Contract in Java [Important Java Interview Question] | Code Decode

preview_player
Показать описание
In this video of code decode we have covered Equals and hashcode contract || Equals and hashcode in Java

Udemy Course of Code Decode on Microservice k8s AWS CICD link:

Course Description Video :

How equals and hashcode contract works in java ?

The default implementation is not enough to satisfy business needs, especially if we're talking about a huge application that considers two objects as equal when some business fact happens. In some business scenarios, developers provide their own implementation in order to force their own equality mechanism regardless the memory addresses.

As per the Java documentation in perspective of equal and hashcode contract, developers should override both methods in order to achieve a fully working equality mechanism — it's not enough to just implement the equals() method.

equals and hashcode in java,equals and hashcode in java by durga,equals and hashcode contract in java,equals and hashcode contract,equals and hashcode in java telusko,equals and hashcode method in java,java equals and hashcode,java equals and hashcode contract,what is equals and hashcode contract,what is equals and hashcode in java,how equals and hashcode works in java,equals and hashcode implementation,hashcode and equals method in java,java,equals and hashcode contract example,contract between equals and hashcode in java

-------------------------------------------------------------------------------------------------------------------------------------

Code Decode Playlists

-------------------------------------------------------------------------------------------------------------------------------------
Subscriber and Follow Code Decode

--------------------------------------------------------------------------------------------------------------------------------------

#equalsandhashcode #equalsandhashcodecontract #java
Рекомендации по теме
Комментарии
Автор

Main point is equals method will get called when for key hashcode value is same.

jiniamitra
Автор

most easy and we explained video very very thanks a lot most helpful video cleared my all doubts keep up the good work .

ragakaplish
Автор

Thanks this is best explanation over the net..

yoshitamahajan
Автор

Surely Aasaam Your explanation and all the topics all very cleared mam

vinieas
Автор

What is the point of multiplying 31 with 1 and then adding it to the int value of id? You can simply add 31 to the id and return. 31 X 1 is 31 only right.

DKRamnani
Автор

Thanks for supporting us .Video is really useful to understand the concept.

sudarshankalvankar
Автор

You are really awesome in explaining things, i seen some other videos of you as well for other topics, really fell in love with your videos Thankyou

rajajodhani
Автор

your explanation is very clear.Please make a video on internals of hashmap

soumyaranjan
Автор

I have some few questions on equals and hashcode _ Advance-Thanks :) _ -
Suppose I have Student and Address class. Address class is field in Student(has a relationship).
If I create two objects of class Student(deep copy - Address is also created)

Is hashcode() return same / equals() return true-

1.What If I don't override equals() and hashcode() in any of class whether the two object are equal.
2.What If I override equals() and Not hashcode() in Student and nothing overridden in Address.
3.What If I only override hashcode() in Student and nothing overridden in Address.
4.What If I override equals() and Not hashcode() in Address and nothing overridden in Student.
5.What If I only override hashcode() in Address and nothing overridden in Student.
6.what if I return always true from equals() and no hashcode overridden in student and nothing overridden in Address

7.what if I return always same value from hashcode() and no equals overridden in student and nothing overridden in Address

8.what if I return always true from equals() and no hashcode overridden in Address and nothing overridden in Student

9.what if I return always same value from hashcode() and no equals overridden in Address and nothing overridden in Student.

satishhawalppagol
Автор

I have a question on hashcode, as you are saying in this video that "hash code is a integer value which defines at which memory location does this particular object is going to store in HashTable" . As we know objects are stored in Heap memory, so does that mean heap memory is constructed using HashTable to store/manage objects ?

rahuldebnath
Автор

Thanks for ur explanation ma'am.... Really helped me to understand it better...

menaceasif
Автор

Hi, Thanks for sharing the video. In your example can you explain hashcode scenario. Like equals can you take one example on hashcode and explain it. Thanks Naveen.

naveenkumarmaddala
Автор

New drinking game: Take a shot every time she says "nothing but the".
JK, nice tutorials.

ShinAkuma
Автор

shouldnt we add @Override annotation for overridng hashcode() ??

srijanbiswas
Автор

your video contents are really great and helpful. But just a suggestion can you please minimize the usage of "NOTHING BUT" while explaining.

saritachoudhury
Автор

I can't tell you enough how awesome you are for making these videos. Thank you

aditis
Автор

Mam u made d variable private in employee class..plz tell me how we will acess or sort dis value in another class...

reeltorealworld
Автор

thanks for the video.. you're doing a great job. all the very best & keep it up.

mohitg
Автор

When you typecasted the object that was passed into Employee type, did you assume that if the id is same the employee name will be same too? since you called it equal only based on the id

dystopianNinja
Автор

Thanks a lot !! This cleared my doubts

AmitKumar-pwln