The following sentences are from SCJP K&B book, page no:543
When using HashSet or LinkedHashSet, the objects you add to them must override hashCode().
If they don't override hashCode(), the default Object.hashCode() method will allow multiple objects that you might consider "meaningfully equal" to be added to your "no duplicates allowed" set.
I would be very thankful,if any one explains the concept in above sentence with detail example.
I wrote the program to understand above concept. The code is as follows:
Can I assume that, because I didn't override the hashCode() of Object class in Employee class, LinkedHashSet is allowing duplicates.
Please correct if I am wrongly understood the above concept?
Thanks in advance?
Have a wonderful day ahead!