public static
abstract class Base implements Comparable {
public Base( Object other ) {
super();
System.out.println( compareTo( other ) );
}
}
public static final class Derived extends Base {
public Derived( String str, Object other ) {
super( other );
this .str = str;
}
public int compareTo( Object other ) {
return str.compareTo( other.toString() );
}
private String str;
}
public static void main( String[] args ) {
Derived derived = new Derived( "Hello World!", "Hello World!" );
}
|
|