反射中关于构造函数的注意

反射中关于构造函数的注意
constructor = klass.getDeclaredConstructor(classes);
上面的函数形式如下:
Constructor getDeclaredConstructor(Class [] argumentTypes);
得到公共或非公共的指定构造函数,其实参与argumentTypes中所列类型匹配.

下面的也需要列出参数,这里的objects就是参数:
return constructor.newInstance(objects);

注意:其他也是如此.

你可能感兴趣的:(反射中关于构造函数的注意)