Here you can find the source of getConstructors(Class> clazz, int args)
public static Constructor<?>[] getConstructors(Class<?> clazz, int args)
//package com.java2s; //License from project: LGPL import java.lang.reflect.Constructor; import java.util.ArrayList; import java.util.List; public class Main { public static Constructor<?>[] getConstructors(Class<?> clazz, int args) { try {//w w w .j a v a 2s . co m List<Constructor<?>> list = new ArrayList<Constructor<?>>(); for (Constructor<?> constructor : clazz.getDeclaredConstructors()) { if (constructor.getParameterTypes().length == args) { constructor.setAccessible(true); list.add(constructor); } } for (Constructor<?> constructor : clazz.getDeclaredConstructors()) if (constructor.getParameterTypes().length == args) list.add(constructor); return list.toArray(new Constructor<?>[list.size()]); } catch (Throwable error) { return null; } } }