首页 > 其他 > 详细

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

时间:2016-04-23 22:58:22      阅读:415      评论: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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!