Possible duplicate:
java generics super keyword
I cannot relate my knowledge to the program below. See below an example program, then my doubts below this program.
import java.util.*; class A { } class B extends A { } class C extends B { } public class sampleprog { public static void main(String[] args) { List<? super A> list1 = new ArrayList<A>(); list1.add(new A());
My doubts: - As far as I know ? super T ? super T means any class you can add is super in T , but is the output different here? Even a subclass has also been successfully added, which is completely confusing. - the output does not differ from the initialization of the list ( List<? super C> list3 = new ArrayList<C>(); ). In this initialization, I assigned list A or B , the output was the same!
Please clarify my doubts.
source share