我有下面的类层次结构。绑定不匹配泛型
一流
class First<T> {
}
二等
class Second<T> extends First<T> {
}
三等
class Third<T extends First<T>> {
}
错误行:
Third<Second<String>> name = new Third<Second<String>>();//Compilation error
Bound mismatch: The type Second<String> is not a valid substitute for the bounded parameter <T extends First<T>> of the type Third<T>
我与上述错误真的很困惑。你能解释为什么这个编译错误发生?
你也可以做'第三个>' –
'第三个> {}'给出编译错误。 –