samedi 8 décembre 2018

Instantiate a generic class with value in Java

I have a generic class, let's call it Foo, type T and value of T in a string form. Now I want to create an instance of Foo<T> with this value.

The way I do it with non-generic classes:

Class<?> cls = Class.forName(fooStr);

But how to provide a template parameter to it?





Aucun commentaire:

Enregistrer un commentaire