开发者

How to declare class that extends generic that extends generic

开发者 https://www.devze.com 2023-02-10 21:32 出处:网络
I have a class that extends generic class that also extends (another) generic class. class B<TypeB> extends C{}

I have a class that extends generic class that also extends (another) generic class.

class B<TypeB> extends C{}
class C<TypeC>{}

and now my probl开发者_StackOverflow社区ems is how to specify the TypeC when creating class A should be something like:

class A extends B<Type1><C<Type2>>

but the above actually does not compile.


Your decl of B should be:

class B<TB, TC> extends C<TC> {
}

and your target will be

class A extends B<ConcreteB, ConcreteC> {
}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号