假设我有一个抽象的a级
public abstract class A<T extends SomeClass, R extends SomeClass> {
...
}
我还有一个b班
public class B<S extends A> {
...
}
如何访问b中的t和r?当我尝试的时候
public class B<F,G,S extends A<F,G>> {
它给出了错误
error: type argument K#1 is not within bounds of type-variable K#2
public class B<F,G,S extends A<F,G>> {
^
where K#1,K#2 are type-variables:
K#1 extends Object declared in class B
K#2 extends SomeClass declared in class A
1条答案
按热度按时间xvw2m8pv1#
只要@johanneskuhn不发表他的评论作为答案:
解决办法是
class B<T extends SomeClass, R extends SomeClass, S extends A<T, R>>