I have an interface, LogParser, consisting of a single method parse(String x). I also have an ArrayList containing the names of multiple classes which all implement LogParser. Is it possible to loop through this list of class names and dynamically instantiate their respective classes and invoke parse(String x)?
The issue I've had is that the classes do not have zero-argument constructors, so I have run into InstantiationException a lot attempting to invoke the parse method through reflection.
Thanks!
Aucun commentaire:
Enregistrer un commentaire