Here you can find the source of getConstructor(Class> cls, Object... parameters)
public static Constructor<?> getConstructor(Class<?> cls, Object... parameters)
//package com.java2s; //License from project: LGPL import java.lang.reflect.*; public class Main { public static Constructor<?> getConstructor(Class<?> cls, Object... parameters) { Constructor<?> constructor = null; for (Constructor<?> classMethod : cls.getConstructors()) { Class<?>[] parametersType = classMethod.getParameterTypes(); boolean match = false; if (parametersType.length == parameters.length) { match = true;/*www. j av a2 s.co m*/ for (int i = 0, length = parametersType.length; i < length; i++) { if (parameters[i] != null) { if (!parametersType[i].isAssignableFrom(parameters[i].getClass())) { match = false; break; } } } } if (match) { constructor = classMethod; break; } } return constructor; } }