Java Class.getConstructor(Class <?>... parameterTypes)

Syntax

Class.getConstructor(Class <?>... parameterTypes) has the following syntax.

public Constructor <T> getConstructor(Class <?>... parameterTypes)    
            throws NoSuchMethodException,
                   SecurityException

Example

In the following code shows how to use Class.getConstructor(Class <?>... parameterTypes) method.


//  w  w w.j  a va  2  s  .co m
import java.lang.reflect.Constructor;

public class Main {

  public static void main(String[] args) throws Exception {

    // returns the Constructor object of the public constructor
    Class cls[] = new Class[] { String.class };
    Constructor c = String.class.getConstructor(cls);
    System.out.println(c);

  }
}

The code above generates the following result.





















Home »
  Java Tutorial »
    java.lang »




Boolean
Byte
Character
Class
Double
Enum
Float
Integer
Long
Math
Number
Object
Package
Process
ProcessBuilder
Runnable
Runtime
SecurityManager
Short
StackTraceElement
StrictMath
String
StringBuffer
StringBuilder
System
Thread
ThreadGroup
ThreadLocal
Throwable