本帖最后由 陈志强 于 2013-6-8 00:46 编辑
- public class reflectDemo2 {
- public static void main(String[] args) throws Exception {
- String startingClassName = args[0];//为什么这里会报错呢?求解</font>
- Method mainMethod = Class.forName(startingClassName).getMethod("main",String[].class);
- mainMethod.invoke(null, (Object) new String[] { "123", "12","1234" });
- }
- }
- class TestArguments {
- public static void main(String[] args) {
- for (String arg : args) {
- System.out.println(arg);
- }
- }
- }
复制代码 这个是错误报告,还请大神解释,谢谢!!!
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
at cn.itcast.gz.reflect.reflectDemo2.main(reflectDemo2.java:11)
|