samedi 4 mai 2019

using getDeclaredMethod java

I've got this piece of code:

Class[] parameter_types = new Class[parametros_servicio.size()];
int i = 0;
while(i < parametros_servicio.size()){
    parameter_types[i] = String.class;
    i++;
}
Method m = c.getDeclaredMethod(nom_servicio, parameter_types);

If I leave it like that, everything works fine. If I change it and I set this parameter_types[i] = Object.class, it doesn't work. The methods I'm working with have only String parameters but I'd like to have some others which can have other datatypes.





Aucun commentaire:

Enregistrer un commentaire