I have a class
public class A<K, T> {
K myk;
T myt;
}
An inherited class looks like the following
public class AExtended extends A<Integer,String>{}
Now I would like to re-use the types of a AExtended
, I am looking for something like this:′
public class B<? extends A<K,T>> { //does not work
K myInt;
T MyString;
public static void createB() {
var b=new B<AExtended>(); //does also not work
}
}
I know, I cloud do the following, but I don't want to re-type all the types of AExtended
. Instead, I want to re-use the types of AExtended
!
public class B<L extends A<K,T>,K,T> {
K myInt;
T MyString;
public static void createB() {
var b=new B<AExtended,Integer,String>();
}
}
question from:https://stackoverflow.com/questions/65941484/use-generics-of-other-class-for-generic-typing