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.
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 ....