Here you can find the source of getConstructor(Class> clazz, Class>... args)
public static Constructor<?> getConstructor(Class<?> clazz, Class<?>... args)
//package com.java2s; //License from project: Open Source License import java.lang.reflect.Constructor; public class Main { public static Constructor<?> getConstructor(Class<?> clazz, Class<?>... args) { for (Constructor<?> c : clazz.getDeclaredConstructors()) if (args.length == 0 && c.getParameterTypes().length == 0 || ClassListEqual(args, c.getParameterTypes())) { c.setAccessible(true);// w w w . j a v a 2 s . c o m return c; } for (Constructor<?> c : clazz.getConstructors()) if (args.length == 0 && c.getParameterTypes().length == 0 || ClassListEqual(args, c.getParameterTypes())) { c.setAccessible(true); return c; } return null; } public static boolean ClassListEqual(Class<?>[] l1, Class<?>[] l2) { if (l1.length != l2.length) return false; for (int i = 0; i < l1.length; i++) if (l1[i] != l2[i]) return false; return true; } }