您的位置:首页 > 大数据 > 人工智能

反射 类的main方法

2013-05-21 16:53 127 查看
@Test
public void test5() throws Exception {
Class c1 = Class.forName("com.lan.reflect.Person");

Method method = c1.getMethod("main",String[].class);

method.invoke(null, new Object[]{new String[]{"aa","bb"}});

method.invoke(null, (Object)new String[]{"aa","bb"});

}


import com.sun.xml.internal.bind.v2.schemagen.xmlschema.List;

public class Person {
public static void main(String[] args) {
System.out.println("main");
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: