vendredi 4 septembre 2020

How to instantiate in Java a class given as a string [duplicate]

I have a package with class files like this:

ClassA.java
ClassB.java
ClassC.java
...
App.java

App.java contains a main function which needs to instantiate an object depending on a given string with a value "ClassX" matching one of the CLass...java classes.

How can I instantiate that class?





Aucun commentaire:

Enregistrer un commentaire