mercredi 5 juin 2019

Returned class defined by parameters method. Reflection java

I have an important question about a problem of reflection Java:

I want create a method that return a value of type, but the type I want stablish by parameter of this method.

For example:

ArrayList<Client> c = MyClass.getInfo(ArrayList<Client>);

or

Set<Client> c = MyClass.getInfo(Set<Client>);

or

HashSet<Person> p = MyClass.getInfo(HashSet<Person>);

It is possible?. How can I implement this method "getInfo" correctly?. I have tried a lot of versions but I never it run!.

Thanks very much by your help!!.





Aucun commentaire:

Enregistrer un commentaire