mercredi 1 juin 2016

Using a Class

This question already has an answer here:

I'm trying to use reflection to get a list of classes implementing an abstract class, Detector. I would like to use the elements of this list (of type Class<T extends Detector>) as a type parameter for another class, DetectorWrapper<T extends Detector>, so that I can easily instantiate T within that class (i.e., using new T(...)). Is it possible to use reflection for this, or should I instead pass Class<T> to DetectorWrapper and use reflection to invoke the constructor whenever I need an instance of T?





Aucun commentaire:

Enregistrer un commentaire