The following type is not possible,
static <T> List<T> passed(List<T extends Taught>)
Because static cannot be generic. Remove the
<T>
infront of
static
and you are left with the same generic function declaration that you had previously. :laugh:
If you want to use generic return types (which you want to use!) then you need to create a generic class in Java. The class would determine what type of return values would be used. That would look something like the following,
class MyClass <T> {
public MyClass() {
}
static <T extends Object> T passed (Class<T> paramType) {
}
}
MyClass<string> obj = new MyClass<string>();
You can change the generic parameters to support the non-reference types (the primitive, int, double etc. types). But I would leave that upto you. :-)
Create instance of generic type in Java? - Stack Overflow[
^]
java - How do I make the method return type generic? - Stack Overflow[
^]