This question already has an answer here:
For example I've:
class My{ void f(String s, int i){}}
OK, if I iterate all class method of "My", I get f parameter types as "java.lang.String" and "int". No problem. But when I use
My.class.getMethod(new Class[]{String.class, int});
It gives me a compilation error. Seems the primitive type of "int". If I change to
{String.class, Integer.class}
Then compilation is OK, but runtime exception of "NoSuchMethodException".
So my question is, in my case how to call "getMethod" to get back My.f()?
Thanks a lot!
Aucun commentaire:
Enregistrer un commentaire