I am new to java and I read many articles on the net about ? super T
or ? extends T
but I still don't get it. Here is my example:
public class A<T> {
private T t;
public T getT() {
return t;
}
public void setT(T t) {
this.t = t;
}
public void doExtends(A<? extends T> b) {
T t = b.getT(); //ok
this.setT(b.getT()); // ok
b.setT(this.getT()); // error
}
public void doSuper(A<? super T> b) {
T t = b.getT(); // error
this.setT(b.getT()); // error
b.setT(this.getT()); // ok
}
}
why are there errors? my question is different then the one referenced in comments