Max
Max

Reputation: 1342

How to declare class that extends generic that extends generic

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 problems 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.

Upvotes: 0

Views: 627

Answers (1)

Victor Sorokin
Victor Sorokin

Reputation: 11996

Your decl of B should be:

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

and your target will be

class A extends B<ConcreteB, ConcreteC> {
}

Upvotes: 6

Related Questions