Live Breaking News & Updates on Effective Java Second Edition

Stay updated with breaking news from Effective java second edition. Get real-time updates on events, politics, business, and more. Visit us for reliable news and exclusive interviews.

artima - How to Write an Equality Method in Java


How to Write an Equality Method in Java
by Martin Odersky, Lex Spoon, and Bill Venners
June 1, 2009
equals method that preserves the contract of
equals even when subclassses of concrete classes add new fields.
In Item 8 of
1, Josh Bloch describes the difficulty of preserving the
equals contract when subclassing as a “fundamental problem of equivalence relations in object-oriented languages.” Bloch writes:
There is no way to extend an instantiable class and add a value component while preserving the equals contract, unless you are willing to forgo the benefits of object-oriented abstraction.
Chapter 28 of
Programming in Scala shows an approach that allows subclasses to extend an instantiable class, add a value component, and nevertheless preserve the ....

United States , Joshua Bloch , Martin Odersky , Stephen Fink , Josh Bloch , Julian Dolby , Google Inc , Artima Inc , Jini Community Service , Jini Community , Equality Method , Lex Spoon , Liskov Substitution Principle , Effective Java Second , Frank Tip , Object Identity Using Relation , Effective Java Second Edition , Artima Developer , Java Virtual Machine , Georgia Tech , ஒன்றுபட்டது மாநிலங்களில் , ஜோஷுவா ப்லோக் , ஸ்டீபன் ஃபிங்க் , ஜோஷ் ப்லோக் , கூகிள் இன்க் , ஜாவா மெய்நிகர் இயந்திரம் ,