Здравствуйте, ojow, Вы писали:
[skipped]
Не очень кошерно, но может так?
package ru.rsdn.generics;
import org.junit.Test;
public class TestGenerics {
public interface Copyable<T extends Copyable<? super T>> {
void copy(T t);
}
public class A implements Copyable<A> {
protected final String a = "--A--";
public void copy(A t) {
System.out.println(t.a);
}
}
public class B extends A {
private final String b = "--B--";
// it's not override
public void copy(B t) {
super.copy(t);
System.out.println(t.b);
}
}
@Test
public void testCopy() {
final A a0 = new A();
final A a1 = new A();
a0.copy(a1);
final A a = new A();
final B b = new B();
a.copy(b);
final B b0 = new B();
final B b1 = new B();
b0.copy(b1);
}
}