equals() and hashCode() : equals method « Utility Classes « SCJP






Use == to determine if two reference variables refer to the same object.

Use equals() to determine if two objects are meaningfully equivalent.

If x.equals(y) is true, then x.hashCode() == y.hashCode() is true.

If you override equals(), override hashCode().








8.2.equals method
8.2.1.equals() and hashCode()
8.2.2.The signature of equals() from Object class is 'public boolean equals(Object object)'
8.2.3.Implementing an equals() Method