Understanding the generated hash code override in Java, line by line

Alonso Del Arte
17 min readJan 14, 2020
Photo by Pepi Stojanovski on Unsplash

When you override equals() in a Java class, you should also override hashCode(). You can certainly write equals() yourself and then have your integrated development environment (IDE) generate hashCode() for you.

There’s nothing wrong with that, provided that you understand what was generated and why. That’s what this article is about.

--

--

Alonso Del Arte

is a Java and Scala developer from Detroit, Michigan. AWS Cloud Practitioner Foundational certified