Here you can find the source of getConstructor(final Class
Parameter | Description |
---|---|
clazz | The represented class |
parameterTypes | The parameter types of constructor |
public static <T> Constructor<T> getConstructor(final Class<T> clazz, final Class<?>... parameterTypes)
//package com.java2s; //License from project: Apache License import java.lang.reflect.Constructor; public class Main { /**/* w w w .j a v a2s . c om*/ * Returns the public constructor of the specified class or null if no such * constructor * * @param clazz * The represented class * @param parameterTypes * The parameter types of constructor * @return the matched constructor or null if not found */ public static <T> Constructor<T> getConstructor(final Class<T> clazz, final Class<?>... parameterTypes) { try { return clazz.getConstructor(parameterTypes); } catch (final Exception e) { return null; } } }