•
Constructor<T>getDeclaredConstructor(类<?>... parameterTypes)返回一个 Constructor对象,该对象反映Constructor对象表示的类或接口的指定 类函数。
•
Constructor<?>[]getDeclaredConstructors()返回一个反映 Constructor对象表示的类声明的所有Constructor对象的数组 类 。
•
Constructor<T>getConstructor(类<?>... parameterTypes)返回一个 Constructor对象,该对象反映Constructor对象表示的类的指定的公共类函数。
•
Constructor<?>[]getConstructors()返回包含一个数组 Constructor对象反射由此表示的类的所有公共构造类对象
有参反射构造
Constructor con = 类的类对象.getConstructor(String.class , int.class);
类的实例 ins = con.newInstance("zhangsan",12);
无参构造
Constructor con = 类的类对象.getConstructor();
类的实例 ins = con.newInstance();
无参构造简化
类的实例 ins = 类的类对(Stri
评论区