Friday, March 28, 2008

Do-it-yourself equals and hash code methods

Usually you can depend on the Java Object uberclass to provide your class with adequate .equals (to determine two objects's equality) and hashCode() (to index your object within a hash).
But sometimes, you just need a little more. You can override these methods and give your own classes more specific instructions about what to do when they are being tested for equality or being indexed. I still have much to learn about this, but found a tasty looking link for further, later perusal.
http://www.geocities.com/technofundo/tech/java/equalhash.html

No comments: