非通用类扩展通用类是什么意思 [英] What does it mean for a non generic class to extend a generic class
本文介绍了非通用类扩展通用类是什么意思的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
public class B extends C <A> {
}
这是什么意思? C需要扩展A吗?我要施加什么额外的限制,而不仅仅是说B扩展了C?
What does this mean? That C needs to extend A? What extra restriction am I putting instead of just saying B extends C?
推荐答案
在这种情况下,C
是可以采用通用参数的类,并且您将其指定为特定的类型A
作为参数.然后,B
扩展了C
的特定参数.
In this case, C
is a class that can take a generic parameter, and you are giving it a specific type A
as the parameter. Then, B
extends that specific parameterization of C
.
例如,假设:
class C<T> {
T example();
}
class B extends C<Integer> {
}
然后B.example()
将返回Integer
.
这篇关于非通用类扩展通用类是什么意思的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文