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 日
如果觉得我的文章对你有用,请随意赞赏