我在类中有一个方法如下
class Sample{
public void doSomething(String ... values) {
//do something
}
public void doSomething(Integer value) {
}
}
//other methods
.
.
.
Run Code Online (Sandbox Code Playgroud)
现在我得到IllegalArgumentException:下面的参数数量错误
Sample object = new Sample();
Method m = object.getClass().getMethod( "doSomething", String[].class );
String[] arr = {"v1","v2"};
m.invoke( object, arr ) // exception here
Run Code Online (Sandbox Code Playgroud)