Get the generic type of the generic type

If i have

public abstract class SomeType<T extends SomeOtherType> {}

public class WrapperType<U extends SomeType<T>> {}

Is there a way to change the last signature (which is an error "cannot resolve the T character) so that I can use the generic type in WrapperType, say for List<T>or something like that?

(If I asked this question using the wrong terminology, I would appreciate corrections.)

+4
source share
1 answer

It is quite simple as soon as you realize what is happening. You have not defined Tin the class area WrapperType. Declare it at least with the same boundaries as in SomeType.

class WrapperType<T extends SomeOtherType, U extends SomeType<T>> {}
+5
source

All Articles