Equality in Java is a Hot Topic, but a Hazardous one.
It seems that comparing two objects isn't as a simple task to do as it seems at first.
2 main points that you have to be careful to (Others are also detailed in this article) :
hasCode()has to be redefined usually since otherwise the equality contract on
Object.hascode()would be broken.
equals()has to take an Object as parameter since overloading in Java is resolved by the compile-time type of the argument, not the run-time type.
I just got bitten by the second one, but not much (yet) since I mostly rely on compile-time overloading. My purpose here was only to compare objects either to constants or to simple variables. But in the generalization I would certainly have overlooked this and be bitten much more deeply.
 But as much as I wished it to be, it is not related :-)