Winston Gutkowski wrote:It is required (or certainly advisable) if you use super.equals() because of the way Object.equals() is implemented.
Reading your article, I now understand what you mean here. I still disagree.
If this == obj, but we don't return prematurely, the method will still naturally return true. super.equals(this) will always return true (assuming the superclass is well-behaved). Then, if the Sub comparison is also well-behaved, the reflexivity property will hold for the entire method, regardless of the initial identity check. The check is just a performance boost.
Wink, wink, nudge, nudge, say no more, it's a tiny ad: