反射 类的main方法

	@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");
	}
}

你可能感兴趣的:(反射 类的main方法)