使用反射机制创建带构造参数的对象

使用反射机制创建带构造参数的对象

private T construct(
Class clazz,
Class<?>[] parameterTypes,
Object[] parameterValues) throws Exception {

Constructor cons = clazz.getDeclaredConstructor(parameterTypes);

return cons.newInstance(parameterValues);
}

posted on 2017-07-03 18:26  zyunx  阅读(706)  评论(0)    收藏  举报

导航