public class Likefr {
public static void main(String[] agrs) throws ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException {
Class clazz=Class.forName("com.Demo.person");
Constructor c=clazz.getConstructor(String.class,int.class,String.class);
person p=(person)c.newInstance("Likefr",20,"男");
Method m=clazz.getMethod("print");
m.invoke(p);
}
}
最后修改:2020 年 08 月 01 日
© 允许规范转载