C# difference between == and Equals()

When == is used on an expression of type object, it’ll resolve to System.Object.ReferenceEquals. Equals is just a virtual method and behaves as such, so the overridden version will be used (which, for string type compares the contents).

What issues should be considered when overriding equals and hashCode in Java?

The theory (for the language lawyers and the mathematically inclined): equals() (javadoc) must define an equivalence relation (it must be reflexive, symmetric, and transitive). In addition, it must be consistent (if the objects are not modified, then it must keep returning the same value). Furthermore, o.equals(null) must always return false. hashCode() (javadoc) must also be … Read more