why does it work? I understood taht "? super Father" only allows Father and GrandFather
Code here-------------------
public class RxTest {
public static void main(String[] args) {
// extends -> read only
// super -> write only
List<? super Father> list = new ArrayList<>();
list.add(new Child());
list.add(new Child());
System.out.println(list.size()); // 2
// why does it work? I understood taht "? super Father" only allows Father and GrandFather
}
}
class GrandFather { }
class Father extends GrandFather { }
class Child extends Father { }