Here\'s a Java generic pattern:
public T getResultData(Class resultClass, other_args) {
...
return resultClass.cast(T-thing);
}
So if I understood correctly what you really trying to do is (illegal pseudo-syntax):
public T getResultData(Class> resultClass, other_args) {
...
return resultClass.cast(T-thing);
}
You can't because you can't further parameterize generic type T
. Messing about with java.lang.reflect.*
won't help:
Class
and thus no way to dynamically create its instance.T