public class XYZ {
public static void main(String[] args) {
C<A> c = new D<A>();
我收到错误:::绑定不匹配:类型A不是有界参数的有效替代&lt; T extends B&lt; T&gt;&gt; C&lt; T&gt;类型的C&gt; 。我究竟做错了什么? }
}
class D<T extends B<T>> implements C<T>{
@Override
public void ok(T b) {
System.out.println(b.getId());
}
}
interface C<T extends B<T>>{
void ok(T b);
}
class A extends B<String>{
}
class B<T>{
private T id;
public T getId() {
return id;
}
public void setId(T id) {
this.id = id;
}
}