1

I would like to instantiate a class MyClass by setting the parameter K dynamically using a method

MyClass myClass = new MyClass<classDecider.getType()>();

Is this possible? What would the return value of getType() be in that case?

The reason I would like to do this is I have several classes that I need parameterized in various places in my code. As I support more classes for these operations, I would like not to have to back and edit every place where this instantiation happens. Thanks in advance for any help.

Aviral
  • 1,141
  • 1
  • 10
  • 16

0 Answers0