Skip to content

Instantly share code, notes, and snippets.

@mailtoharshit
Created August 28, 2012 01:08
Show Gist options
  • Save mailtoharshit/3494041 to your computer and use it in GitHub Desktop.
Save mailtoharshit/3494041 to your computer and use it in GitHub Desktop.
The equals method with this signature:
public Boolean equals(Object obj) {
// Your implementation
}
Keep in mind the following when implementing the equals method. Assuming x, y, and z are non-null instances of your
class, the equals method must be:
◊ Reflexive: x.equals(x)
◊ Symmetric: x.equals(y) should return true if and only if y.equals(x) returns true
◊ Transitive: if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true
◊ Consistent: multiple invocations of x.equals(y) consistently return true or consistently return false
◊ For any non-null reference value x, x.equals(null) should return false
The equals method in Apex is based on the equals method in Java.
The hashCode method with this signature:
public Integer hashCode() {
// Your implementation
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment