Brian

12%
Flag icon
Also, this approach can cause infinite recursion: Suppose there are two subclasses of Point, say ColorPoint and SmellPoint, each with this sort of equals method. Then a call to myColorPoint.equals(mySmellPoint) will throw a StackOverflowError.
Brian
Feeling dense: why does this cause infinite recursion to have a class type check and fall back on parent equals() method? Oh is the key that it’s taking equals(Object o) and calling o.equals() in each subclass, so it’s ping-ponging back and forth between the two subclasses’ implementations?
Effective Java
Rate this book
Clear rating
Open Preview