Understanding equals() and hashCode() in Java: Why Your HashMap Might Be Misbehaving

Why your Java HashMap or HashSet may not work as expected and how equals() and hashCode() can silently break your collections.