Skip to content

Instantly share code, notes, and snippets.

@mkolakow
mkolakow / onHashCodeAndEquals.markdown
Created December 1, 2011 03:11 — forked from squarepegsys/onHashCodeAndEquals.markdown
Some thoughts on .hashCode and .equals in Java

Thoughts about .equals and .hashCode

Here is a little context: we were tracking down a memory leak in our application and saw this big HashMap in the dump file. The HashMap was from ehcache. The problem was that the objects that were used as the key did not implement .hashCode. Oops. We used Eclipse's generated .equals and .hashCode to get us by and that got us through the heat of the moment.

So, today, a couple of developers were on a PMD/FindBugs hunt and,