Here you can find the source of getConstructor(Class
Parameter | Description |
---|---|
targetClass | from which constructor is returned |
parameterTypes | of constructor |
T | type of the target class object. |
public static <T> Constructor<T> getConstructor(Class<T> targetClass, Class<?>... parameterTypes)
//package com.java2s; // License as published by the Free Software Foundation; either import java.lang.reflect.Constructor; public class Main { /**//from w w w .j a v a 2 s. c o m * Gets constructor of targetClass. * @param targetClass * from which constructor is returned * @param parameterTypes * of constructor * @param <T> type of the target class object. * @return constructor of targetClass or {@link IllegalStateException} if any exception occurs * @see Class#getConstructor(Class[]) */ public static <T> Constructor<T> getConstructor(Class<T> targetClass, Class<?>... parameterTypes) { try { return targetClass.getConstructor(parameterTypes); } catch (NoSuchMethodException ex) { throw new IllegalStateException(ex); } } }