I have about 7 classes that all need to implement the Comparable interface. Is it better to have each implement them separately or to implement Comparable in the superclass of those 7 classes? My compareTo(Object o) method should be the same for all 7 classes with the one exception being that whatever class is executing the Comparable interface should only be comparing to a class of the same type. So I guess, what I'm asking is, is there a way to change the Object parameter to the type I need to compare to inside of the code. I would use instanceof, but no one would ever know, in the future, what I would need an instance of...
I'm trying to use Generics with this, but it doesn't make sense to do so in the superclass. Any help would be appreciated.
I'm trying to use Generics with this, but it doesn't make sense to do so in the superclass. Any help would be appreciated.