Answer the question
In order to leave comments, you need to log in
Is it possible in java to inherit a generic class from another generic class?
Is it possible to inherit a generic class by another generic class, so that the derived class can only accept as a parameter the descendants of a particular class?
Below is the crux of the issue.
class class1<T> {
...
}
class class2<T extends SomeType> extends class1<T> {
...
}
Answer the question
In order to leave comments, you need to log in
I have created two classes:
public class Class1<T> {
public void Run(T another){
//TODO Do something with another
}
}
public class Class2<T extends Synker> extends Class1<T> {
}
Class2<Synker> cl = new Class2<>();
cl.Run(new Synker());
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question