This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin Cookbook and have Ken Kousen on-line!
See this thread for details.
Win a copy of Kotlin Cookbook this week in the Kotlin forum!

Jonh Dash

Greenhorn
+ Follow
since Jan 10, 2020
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
3
Given in last 30 days
3
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Jonh Dash

I wanna ask you, till we are in the subject, now I reed Joshua Bloch - Effective Java and I search for other interesting books. Can you offer me some other books, like best practices, books explaining things like this topic, things that you have to know and etc?
2 weeks ago
First, thank you all. It is a great honor to see, that one of the best replyers replied to me quickly, to my first question.

It makes sense Junilu Lacar, a lot actually. It is a good analogy and clears how exactly works these collections.

I have seen similar code examples and now better understand why that happens.

It is a great example when I need to override them.
Now I finally understand why hash collections need both methods to work correctly and why it's important to override them. It definitely makes a lot of sense now and I can say with confidence that I know when and why they are used.

Thanks again for your time and help.
2 weeks ago
Hello to all.

It bugs me something. Please help me figure out why exactly we override equals() and hashCode() methods. I read that we must override both methods because they are used by Hash collections.

For what I can understand, hashCode() is needed because in adding an element(in a hash collection) it adds it to a bucket based on hashCode() value (I read it somewhere that this is obj address maybe???), and equals() it use if we add some other obj, compares it to the other.

Frankly speaking, I don't know if I am mistaking and I am not 100% sure, why it needs both methods and when exactly it uses them.
2 weeks ago