//On page 572 of Sierra & Bates study guide you'll find the following code:
Could anyone please explain to me why this overriding of compareTo() should work.
The only thing I see is that this is an endless recursive call (we are calling compareTo()
from within compareTo()) which will crash the program.
Though equals is not implemented in this example but its worth noting that if you are implementing equals() and compareTo() then they both must be consistent to each other e..g compareTo() must return zero for two objects which are equal via equals() method.
I'm confused about this as well.
the following code:
what i'm confused about is the this object being passed to compareTo() which one is it?, i would like to know which title is being used to compare to DvDInfo.title?
Also is the compareTo() being called only once by Collections.sort()? what code is being used inside compareTo()?