Methods Common to All Objects
Follow The Guidelines Of The Equals-Method
The equals-method need to obey the following four rules to remain functional.
Reflexive: x.equals(x) = true
Symmertric: x.equals(y) = y.equals(x)
Transitive: x.equals(y) = y.equals(z) = true -> z.equals(x) = true
Consistent: x.equals(y) remains the same as long as x and y does not change.
How to write a good equals method:
(Regardless of most IDEs autogenerating them)
First use == to check if the object is equivilent to “this”.
Use instanceof to check if the object is the correct class instance. Otherwise return false.
Cast the object to the same instance as “this”
Check with == if all relevant fields of the class match each other.










