求大神指导,为什么会抛数组下标越界异常。
import java.lang.reflect.Method;
class TestArguments {
public static void main(String[] args) {
for(String arg : args) {
System.out.println(arg);
}
}
}
public class MethodTest {
public static void main(String[] args) throws Exception {
String str1 = "abc";
String startingClassName = args[0];
Method mainMethod = Class.forName(startingClassName).getMethod("main", String[].class);
mainMethod.invoke(null, new Object[]{new String[]{"111","222","333"}});
mainMethod.invoke(null, (Object)new String[]{"111","222","333"});
}
}