Java Class.getConstructors()
Syntax
Class.getConstructors() has the following syntax.
public Constructor <?>[] getConstructors() throws SecurityException
Example
In the following code shows how to use Class.getConstructors() method.
// w w w. j a va2 s. c o m
import java.lang.reflect.Constructor;
public class Main {
public static void main(String[] args) throws Exception {
Class cls = Class.forName("java.lang.String");
System.out.println("Panel Constructors =");
/* returns the array of Constructor objects representing the public
constructors of this class */
Constructor c[] = cls.getConstructors();
for(int i = 0; i < c.length; i++) {
System.out.println(c[i]);
}
}
}
The code above generates the following result.