是否犯了低级错误? 与视频一样但报错??
- 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"});
复制代码
- class TestArguments{
- public static void main(String[] args){
- for(String arg : args){
- System.out.println(arg);
- }
- }
- }
复制代码
错误: Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
为啥呢? |
|