Java Equals

Guides

Java Object Equality without Public Fields or Getters

As a best practice in Java, POJO classes or Data objects always declare the fields private and expose their access through the getter methods. On rare occasions, we may encounter situations when the member fields are private, and the class does not provide the public accessor methods. For example, the class may have been generated …

Java hashCode() and equals() Methods

Java hashCode() and equals() methods. Learn contract between hashCode and equals methods. How to correctly override both methods and best practices.

About Us

HowToDoInJava provides tutorials and how-to guides on Java and related technologies.

It also shares the best practices, algorithms & solutions and frequently asked interview questions.