Java Reflection Constructor Get getConstructor(Class clazz, Class[] parametersTypes)

Here you can find the source of getConstructor(Class clazz, Class[] parametersTypes)

Description

Gets the constructor with specified parameter types.

License

Open Source License

Parameter

Parameter Description
clazz Class, which constructor will be returned.
parametersTypes Array of parameters types, that will be used for getting constructor.

Exception

Parameter Description
Exception To JUnit.

Return

Constructor.

Declaration

public static Constructor getConstructor(Class clazz, Class[] parametersTypes) throws Exception 

Method Source Code

//package com.java2s;

import java.lang.reflect.Constructor;

public class Main {
    /**/*from  w ww  .j a v  a 2  s  . co  m*/
     * Gets the constructor with specified parameter types.
     *
     * @param clazz Class, which constructor will be returned.
     * @param parametersTypes Array of parameters types, that will be used for getting constructor.
     * @return Constructor.
     * @throws Exception To JUnit.
     */
    public static Constructor getConstructor(Class clazz, Class[] parametersTypes) throws Exception {
        return clazz.getDeclaredConstructor(parametersTypes);
    }
}

Related

  1. getConstructor(Class clazz, Class... argTypes)
  2. getConstructor(Class clazz, Class[] argTypes)
  3. getConstructor(Class clazz, Class[] paramTypes)
  4. getConstructor(Class clazz, Class[] paramTypes)
  5. getConstructor(Class cls, Class[] args)
  6. getConstructor(Class clz, Class expectedTypes[])