码迷,mamicode.com
首页 > 其他好文 > 详细

A<T extends B> and A <? extends B>

时间:2016-04-23 22:59:28      阅读:511      评论:0      收藏:0      [点我收藏+]

标签:

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

(1)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!