Marshall Schor wrote: > > public class Super implements WritableComparable<Super> { > . . . > public int compareTo(Super o) { > // sort on string value > . . . > } > > I implemented the 2nd key class (let's call it Sub) > > public class Sub extends Super { > . . . > public int compareTo(Sub o) { > // sort on boolean value > . . . > // if equal, use the super: > ... else > return super.compareTo(o); > } > The overridden method must have same arguments as the parent class method. Otherwise it is just another method, not an overridden one. In your case, if the current code looks like error prone, you can make Super also as a template. Then you can use the Sub class in the compareTo method However you will have to cast in the Super class.
class Super<T> implements WritableComparable<T> { public int compareTo(T o) { Super other = (Super) o; .... } } class Sub extends Super<Sub> { public int compareTo(Sub o) { ... } } -Sharad