What is the difference between List<T>
and List<? extends T>
? I have read http://docs.oracle.com/javase/tutorial/java/generics/bounded.html but it is still not clear to me.
Asked
Active
Viewed 2,961 times
1

José D.
- 4,175
- 7
- 28
- 47
-
I don't think this is a duplicate with that question at all. – José D. Oct 20 '14 at 10:47
-
1I can't answer, so I will comment what I think is the real answer to my question: List
represents a List of T elements (each element can be a T or any subclass of T). List extends T> represents a List where U extends T. That means you can't add a 'T' element to a List extends T> (because it could be a List such that U extends T but the generic T you are trying to add to the list is not of type U) but you can always add a 'T' element to a List – José D. Oct 20 '14 at 10:49. (There are other differences)