PrepZone Logo
PrepZone
Back to Java

Java · Medium

What happens if you override equals() without overriding hashCode()?

JavaCollections

Answer preview

Hash-based collections break silently. — Two logically equal objects may return different hashCode() values (inherited from Object, which uses the memory address).…