[英]Java Generics: what does <? extends Interface <?>> mean?
Further to a previous post I'm hope someone can help clarify/confirm my understanding of the following java generics statements, and offer some input as to what the final one means: 在上一篇文章之后,我希望有人可以帮助澄清/确认我对以下java泛型语句的理解,并提供一些有关最终含义的信息:
If: 如果:
Class<abc> className = x
means to assign x
of type abc
to Class
variable className
表示将
abc
类型的x
分配给Class
变量className
And: 和:
Class<? extends IAbc> className = x
means to assigns x
which implements interface IAbc
to Class
variable className
将实现接口
IAbc
x
分配给Class
变量className
What does: 是什么
Class<? extends IAbc<?>> className = x
mean? 意思?
That just means that IAbc
is itself a generic type IAbc<T>
, you're asking for a Class
object representing some implementation of some parameterization of IAbc
but you don't know (or care?) which. 那只是意味着
IAbc
本身就是泛型类型IAbc<T>
,您要的是一个Class
对象,该对象表示IAbc
的某些参数化的某种实现,但您不知道(或不在乎)哪个。
More interesting would be something like 更有趣的是
Class<? extends IAbc<? extends Number>>
which would accept any class that implements IAbc<Number>
, IAbc<Integer>
, IAbc<Double>
, etc. 它将接受实现
IAbc<Number>
, IAbc<Integer>
, IAbc<Double>
等的任何类。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.