This question already has an answer here:
I have a method in a class as below
class Sample{
public void doSomething(String ... values) {
//do something
}
public void doSomething(Integer value) {
}
}
//other methods
.
.
.
If I want to get the first doSomething method which has argument of type String ... by using getMethod(String name, Class... parameterTypes):Method of Class.java, what should be the Class which I need to pass in getMethod().
Sample object = new Sample();
Method m = object.getClass().getMethod( "doSomething, [what should I pass
here?]" )
Aucun commentaire:
Enregistrer un commentaire