标签:
Refer to
http://stackoverflow.com/questions/5211548/what-is-the-difference-between-at-extends-b-and-a-extends-b
First of all, those are completely different constructs used in different contexts.
A<T extends B> is a part of generic type declaration such as
public class A<T extends B> { ... }
It declares generic type A with type parameter T, and introduces a bound on T, so that T must be a subtype of B.
A<? extends B> is a parameterized type with wildcard, it can be used in variable and method declarations, etc, as a normal type:
A<? extends B> a = ...;
public void foo(A<? extends B> a) { ... }
Variable declaration such as A<? extends B> a means that type of a is A parameterized with some subtype of B.
A<T extends B> and A <? extends B>
标签:
原文地址:http://www.cnblogs.com/chuiyuan/p/5425840.html