You can now attach files to a post so here is a NetBeans project giving the classes from the original article and a test file.
You can now attach files to a post so here is a NetBeans project giving the classes from the original article and a test file.
Comments
New comment
Hi Martin
If you are overriding equals() you'd better be overriding hashCode() too!
arb
neo
New comment
Hi Neil, thanks for pointing this out.
The original article this code belongs to does discuss requirements for overriding hashCode() under each of the three possible equality relationships: 1) equals not overridden in subclass so do not override hashCode(). 2) equals overridden, subclass instance can never be equal to super-class instance: override hashCode(). 3) equals overridden, but subclass instance may be equal to superclass instance when fields match those of a super: either do not override hashCode() and rely on the overridden equalFields() to sort collisions or ensure that significant field values that allow comparison with a super are then excluded from the hashCode computation.
Have added a link to the original (now that 'permalimks' are available in OU blogs and can make linking more specific than relying on tags)