本帖最后由 张向辉 于 2013-1-18 17:48 编辑
public static void main(String[] args) throws Exception {
Class clazz=Class.forName("cn.itcast.reflect.Person");
Method method =clazz.getMethod("main",String[].class);
method.invoke(null,new Object[]{new String[]{"aaa","bbb"}});
}
编译通过
运行错误:
Exception in thread "main" java.lang.NoSuchMethodException: cn.itcast.reflect.Person.main([Ljava.lang.String;)
at java.lang.Class.getMethod(Unknown Source)
at cn.itcast.reflect.Demo3.main(Demo3.java:16)
|