Getting a Constructor of a Class Object: By obtaining a list of all Constructors object : Constructor « Reflection « Java
- Java
- Reflection
- Constructor
Getting a Constructor of a Class Object: By obtaining a list of all Constructors object
import java.lang.reflect.Constructor;
public class Main {
public static void main(String[] argv) throws Exception {
Constructor[] cons = String.class.getDeclaredConstructors();
for (int i = 0; i < cons.length; i++) {
Class[] paramTypes = cons[i].getParameterTypes();
System.out.println(cons[i]);
}
}
}
Related examples in the same category