Equals and hashcode contract

  Рет қаралды 85,959

Ranjith ramachandran

Ranjith ramachandran

Күн бұрын

What happens when equal objects do not have equal hashcode?
The objects will cause bugs when used with hash-based collections.
All hash based operations will depend on default hashcode implementation that will return unique hashcode for each object - and hence hashmap will not be able to look up keys, hashset will allow duplicates. In this video I demonstrate this.
#java #macbookair #apple #easy #javainstitute #hashcode #handset #video #equals #javaprogramming #study #learnjava #learning #coaching #fypシ #fypシ゚viral #trending #india #fyp

Пікірлер: 89
@anuragbharti3773
@anuragbharti3773 3 жыл бұрын
Awesome explanation
@christopherbarrett9900
@christopherbarrett9900 8 жыл бұрын
Great example. I love when people post examples along with the theory. Good job
@svalyavasvalyava9867
@svalyavasvalyava9867 Жыл бұрын
clear explanation, thank you!!!
@varungudisena9463
@varungudisena9463 10 ай бұрын
very good explanation
@vikrantkumarsmvdu
@vikrantkumarsmvdu 6 жыл бұрын
Hi Ranjith, Videos which you have uploaded are very clear to understand. You should upload more videos on different concepts. It will be very helpful to other people.
@ramc7460
@ramc7460 7 жыл бұрын
Awesome explanation I ran out of videos from your channel . We expect many videos from different concepts Great work keep going
@SuprajaYKM
@SuprajaYKM 5 жыл бұрын
very nice explanation
@MrThanique
@MrThanique 7 жыл бұрын
EXCELLENT ONE. Thanks a lot for sharing
@rohitkarambali779
@rohitkarambali779 2 жыл бұрын
sir aap please aur topics pe bhi vdos banaye, its very helpful and knowledgeable for us, u r doing great job
@amit-vg6cb
@amit-vg6cb 7 жыл бұрын
Thanks for posting this video...I have watched many videos on the same concept , but did not get clear idea about this, now I am crystal clear on this topic. Keep posting !!
@aruntcs2005
@aruntcs2005 7 жыл бұрын
This is awesome stuff..keep up the good work
@rdayala14
@rdayala14 8 жыл бұрын
Pretty neat, simple explanation!! It is always nice to see examples which explains the content. Keep it up!! Looking forward for more topics!!
@pechorinn
@pechorinn 7 жыл бұрын
Very nice explanation. Good job. Thank you!
@akshoyd7735
@akshoyd7735 5 жыл бұрын
Completely impressed with the content of videos
@rajeshkolluju2409
@rajeshkolluju2409 6 жыл бұрын
Nice and Simple Explanation..Thank q Sir...
@misakyanzye4269
@misakyanzye4269 7 жыл бұрын
Excellent explanation, clear and concise yeah! thanks
@janukhandari501
@janukhandari501 7 жыл бұрын
Very good examples and explanation, hoping to see more videos on topics like threads, spring and more of collections. Thanks
@shashibhushanthakur1982
@shashibhushanthakur1982 6 жыл бұрын
Thanks for this video related to hashCode and equal method
@pavanscala8957
@pavanscala8957 6 жыл бұрын
It is more helpfull to my Job interview point of view, Thank you very much, This is my first video I SUBSCRIBE Thank you
@Sk-zs1cw
@Sk-zs1cw 6 жыл бұрын
Easy to understandable and I learnt so many things about eq & hash contract. Plz make video on Thread, synchronisation and thread executor framework
@prawinaela
@prawinaela 6 жыл бұрын
Excellent video, explained very well
@praveen2hearts
@praveen2hearts 8 жыл бұрын
Thanks for the video ... Very informative and crystal clear
@DheerajKumarBarnwal
@DheerajKumarBarnwal 7 жыл бұрын
Superb explanation and very helpful. Keep up the good work. :)
@jeffsulman3558
@jeffsulman3558 6 жыл бұрын
That was very helpful. Thank you!
@rashimpathak8117
@rashimpathak8117 2 жыл бұрын
Beautifully explained.. do add more video on core java and new java versions
@jagadishk1173
@jagadishk1173 2 жыл бұрын
Still watching your videos sir it is very useful actually.. Please make more videos..
@janardhannallapati
@janardhannallapati 8 жыл бұрын
Great videos Ranjith. Please keep posting them.
@rajeshnarasimha5550
@rajeshnarasimha5550 4 жыл бұрын
thank you Ranjith, very useful information & easy to understand..
@AmitKumar-qh4ow
@AmitKumar-qh4ow 8 жыл бұрын
Excellent Tutorial Ranjith. Thanks a lot.
@liferayasif9382
@liferayasif9382 8 жыл бұрын
Thank you so much, awesome tutorial.
@sinnumunnu
@sinnumunnu 5 жыл бұрын
Amazing Explaination!!
@srividya157
@srividya157 6 жыл бұрын
Very well explained..
@coach-okr
@coach-okr 8 жыл бұрын
Thank you very much!!! I watched so many tutorials to understand that... Please, make more tutorials
@aditigoyal2622
@aditigoyal2622 9 жыл бұрын
Thanks Ranjith!... i really appreciate this!
@shank0877
@shank0877 8 жыл бұрын
Great explanation Ranjith. Great job!
@yoganandraju5539
@yoganandraju5539 6 жыл бұрын
Awesome quality bro
@khursheedbano9046
@khursheedbano9046 8 жыл бұрын
Good one..Plz keep posting....
@sachinbhadrashette3077
@sachinbhadrashette3077 8 жыл бұрын
Thank you so much. you explained really very well so that everybody can understand. this is going to help me a lot.
@ranjithramachandran5928
@ranjithramachandran5928 9 жыл бұрын
practical demonstration of mishaps that can happen if you overlook to implement a good hashcode method and expect equals to work with hash based collection. Questions/Suggestions/Criticisms? please post a comment!
@tiwarybaba
@tiwarybaba 7 жыл бұрын
Ranjith ramachandran...no criticism, ur videos are good...u explain things very nicely. hope, u'll make some more videos on other topics. 😇
@Aditya_Valluru
@Aditya_Valluru 6 жыл бұрын
Bit contradiction : If system generated hashcode is different for two objects which have same attributes, then how new object with same key will replace the old one. HashMap hm = new HashMap(); hm.put(1,"aditya"); hm.put(1,"adityaNew"); s.o.p(hm); prints adityaNew Can you please clarify? Also please post some more videos ... its been long time no see :)
@subhankarb100
@subhankarb100 7 жыл бұрын
Thanks !!!! nice explanation...
@kranti7473
@kranti7473 6 жыл бұрын
Pls upload more videos on different java concepts/topics.. Thanks ...
@nitin8692
@nitin8692 6 жыл бұрын
Nice explanation.
@krishnansblr
@krishnansblr 8 жыл бұрын
Excellent video Ranjith ramachandran
@anandprakash3070
@anandprakash3070 6 жыл бұрын
Sir please upload more videos. They are really helpful for us.
@aniketbharsakale2561
@aniketbharsakale2561 5 жыл бұрын
Making complex look simple. would appreciate if there are more clips on other java topics as well. Thumbs Up. :)
@iCrazzyShri
@iCrazzyShri 7 жыл бұрын
Owesome buddy, Really like your videos. I was expecting you would explain why default hashcode will make your objects unique even if it's values are same and equal method is implemented
@spujain
@spujain 8 жыл бұрын
Good explanation..
@bhushan7546
@bhushan7546 7 жыл бұрын
Very nice explanation Ranjit Thanks:D I serach alot on Internet for that i did't find such simple solution :D
@shashisingh7565
@shashisingh7565 3 жыл бұрын
Your videos are quite helpful and you explains concept very well. Plz plz plz make videos on other java concepts like Multithreading, synchronization.
@ravinasomvanshi6844
@ravinasomvanshi6844 6 жыл бұрын
Your videos has some different level as compare to other Java Videos..Thamk u so much.. :) ..Please do a video on Threads in Java and how to avoid dead locks
@srijitpaul4149
@srijitpaul4149 7 жыл бұрын
Nice example.
@kayeshparvez
@kayeshparvez 4 жыл бұрын
this is because, we have to ensure that "For two equal objects we have to generate same hashcode"
@siddharthdg
@siddharthdg 8 жыл бұрын
Please do a video on Threads in Java and how to avoid dead locks .
@nirmalkumarsahoo8683
@nirmalkumarsahoo8683 7 жыл бұрын
Thanks Ranjith ... could you please upload video which explains how serialaizable interface works
@PandeyRavindra1
@PandeyRavindra1 8 жыл бұрын
awesome..
@dhananjaypatankar6995
@dhananjaypatankar6995 6 жыл бұрын
Hello, nice videos. By the way, where are you these days..... Its been a while you have uploaded these videos. I see 2015 videos. Please upload new videos on Java on any concept, there is a learning curve in your videos. I guess, not only me, but many others are also waiting. Thanks.
@rajasekar8054
@rajasekar8054 9 жыл бұрын
thanks Ranjith !!!
@akbarsaleem2228
@akbarsaleem2228 7 жыл бұрын
Thanks Ranjit , it really helpful for me . But one thing i want to know that if we are not implementing hashcode method what internally happening that causes to store duplicate values and not able to get the expected name .
@lokeshreddy7755
@lokeshreddy7755 7 жыл бұрын
please do videos on mutithreading thank u ...
@jackofnotrades15
@jackofnotrades15 2 жыл бұрын
Just to add, the key Employeekey class should also be immutable. As it is being used as key in map.
@SunilKumar-tl6mv
@SunilKumar-tl6mv 7 жыл бұрын
Nice one on equals-hashcode contract. But my doubt is does hashcode implementation depend internally on equals method? Why would hashcode give different hash values if we override equals method?
@nikjpr
@nikjpr 9 жыл бұрын
thanks!!
@sahilsehgal626
@sahilsehgal626 6 жыл бұрын
Hi Ranjith, Can you please make few videos on multi threading and concurrency in java 5 ?
@RoopkishorPandeyji
@RoopkishorPandeyji 6 жыл бұрын
thanks Ranjith, I got 1 questions in an interview, why hashcode is required, cant only equals method do our job?, If we make our own collection classes, why java wants both equals and hashcode to compare 2 objects.
@romanlotockijj4806
@romanlotockijj4806 7 жыл бұрын
Fine... Understood...
@harishchowdarysure8858
@harishchowdarysure8858 8 жыл бұрын
sir whn u upload thread concurrency.................
@bhushan7546
@bhushan7546 7 жыл бұрын
Please upload Java 8 Feature
@JitendraSingh-zg3ws
@JitendraSingh-zg3ws 8 жыл бұрын
hashset add duplicate elements because internally HashSet use HashMap
@mishikamehta4610
@mishikamehta4610 8 жыл бұрын
Can you provide video on hashtable implementaion?
@ranjithramachandran5928
@ranjithramachandran5928 8 жыл бұрын
+m mehta , please see kzbin.info/www/bejne/mWS1h4ppgKx8f6c
@swap000bhosale
@swap000bhosale 8 жыл бұрын
I want to know why are we overriding equals method is it necessary
@ranjithramachandran5928
@ranjithramachandran5928 8 жыл бұрын
+Swapnil Bhosale - It is necessary when you want to establish equality of your custom Objects. How would you say if your Employee e1 and Employee e2 are same? e1 == e2 check is not sufficient when you establish equality based on fields inside Employee like e1.name, e1.id, etc.
@harishchowdarysure8858
@harishchowdarysure8858 8 жыл бұрын
plz upload thread Concurrency...................reply me?
@vicky10ve
@vicky10ve 4 жыл бұрын
where are you ??? People need you!.. :)
@harishchowdarysure8858
@harishchowdarysure8858 8 жыл бұрын
sir when u upload thread concurrency?
@ranjithramachandran5928
@ranjithramachandran5928 8 жыл бұрын
+harish chowdary sure This week.
@harishchowdarysure8858
@harishchowdarysure8858 8 жыл бұрын
+Ranjith ramachandran Still u doesn't upload Thread Concurrency..............replay me sir...........
@harishchowdarysure8858
@harishchowdarysure8858 8 жыл бұрын
+Ranjith ramachandran Still u doesn't upload Thread Concurrency..............replay me sir...........
@ashishkumarsingh1920
@ashishkumarsingh1920 6 жыл бұрын
I am fan of your videos sir But your playlist is very limited. Please more possible video make and upload Your teaching style and knowledge in java is so high no compare to you in you tube Thanks sir
@arpanbanerjee8584
@arpanbanerjee8584 4 жыл бұрын
Why it will causs bugs..you never explained that! Examples were great. But your explanation was not in details Pls explain why it is necessary to override hashcode if we override equals method. How does that work internally if we don t do the same
@JitendraSingh-zg3ws
@JitendraSingh-zg3ws 4 жыл бұрын
may be you can check out how Hashmap works internally , there is video on this on same channel :)
@anjaliarorafan6587
@anjaliarorafan6587 5 жыл бұрын
Not intereseted
@nishaphilip9745
@nishaphilip9745 2 жыл бұрын
Hi Ranjith, Videos which you have uploaded are very clear to understand. You should upload more videos on different concepts. It will be very helpful to other people.
@ashishagrawal7709
@ashishagrawal7709 8 жыл бұрын
Thank you so much. you explained really very well so that everybody can understand. this is going to help me a lot.
@ranjithramachandran5928
@ranjithramachandran5928 8 жыл бұрын
+ASHISH AGRAWAL Thanks!
@harishchowdarysure8858
@harishchowdarysure8858 8 жыл бұрын
sir whn u upload thread concurrency.................
About java.lang.String, why String is special in java - String tutorial
39:19
Ranjith ramachandran
Рет қаралды 109 М.
HashTable vs HashMap vs Concurrent HashMap all kinds of Map implementations
41:26
КАК ДУМАЕТЕ КТО ВЫЙГРАЕТ😂
00:29
МЯТНАЯ ФАНТА
Рет қаралды 9 МЛН
Summer shower by Secret Vlog
00:17
Secret Vlog
Рет қаралды 8 МЛН
Alex hid in the closet #shorts
00:14
Mihdens
Рет қаралды 13 МЛН
Beautiful gymnastics 😍☺️
00:15
Lexa_Merin
Рет қаралды 15 МЛН
02. Equals and HashCode Contract & Different Variations
11:19
WebEncyclop Tutorials
Рет қаралды 53 М.
Set and HashSet in Java - Full Tutorial
20:43
Coding with John
Рет қаралды 205 М.
JVM ( java virtual machine) architecture - tutorial
29:16
Ranjith ramachandran
Рет қаралды 512 М.
How HashMap works in Java? With Animation!! whats new in java8 tutorial
15:29
Ranjith ramachandran
Рет қаралды 1 МЛН
.equals() vs. == in Java - The Real Difference
8:48
Coding with John
Рет қаралды 182 М.
Java 8 Streams API
15:45
Defog Tech
Рет қаралды 154 М.
Singleton design pattern in Java - Part 2
33:00
Ranjith ramachandran
Рет қаралды 62 М.
Garbage collection in Java, with Animation and discussion of G1 GC
44:20
Ranjith ramachandran
Рет қаралды 485 М.
КАК ДУМАЕТЕ КТО ВЫЙГРАЕТ😂
00:29
МЯТНАЯ ФАНТА
Рет қаралды 9 МЛН