Why both hashcode and. Equals method mentain contract. Or why they can't leave without any one. .........?
Why both hashcode and. Equals method mentain contract. Or why they can't leave without any one. .........?
.equals ( ) method ment for compare between object with content wise
For identifying these object r not same these are different that's why we override hashcode () along with. equals ( )
Example :-
Suppose u have 10 book
2:-java books
4:-framework books
3:-joke books
1:-j2ee book
For identifying these object r not same these are different that's why we override hashcode () along with. equals ( )
Example :-
Suppose u have 10 book
2:-java books
4:-framework books
3:-joke books
1:-j2ee book
U want to keep them in to self how can you store without out knowing the type of books or identification of book.
If you know ohh there is 10 book and both r different after know this u keep separate it in to self
If you know ohh there is 10 book and both r different after know this u keep separate it in to self
Here book identify is done by hashcode
Self:- is container
Book:- object
.equals() searching is same book is there or not content wise. ... 😃😃😃😃😃
Self:- is container
Book:- object
.equals() searching is same book is there or not content wise. ... 😃😃😃😃😃
Comments
Post a Comment