Java Reflection Constructor Get getConstructor(String string, Class... types)

Here you can find the source of getConstructor(String string, Class... types)

Description

get Constructor

License

Open Source License

Declaration

public static Constructor getConstructor(String string, Class... types) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.lang.reflect.Constructor;

public class Main {
    public static Constructor getConstructor(String string, Class... types) {
        try {//ww  w . j  av  a  2 s .  c om
            Class clazz = Class.forName(string);
            Constructor constructor = clazz.getDeclaredConstructor(types);
            constructor.setAccessible(true);
            return constructor;
        } catch (Exception ex) {
        }

        return null;
    }
}

Related

  1. getConstructor(final Class clazz, final Object... constructorArgs)
  2. getConstructor(final Class clazz, final Object... objs)
  3. getConstructor(final Class instantiableClass, final Class... classes)
  4. getConstructor(String className, Class... argClasses)
  5. getConstructor(String cls_name, Class[] param_cls)
  6. getConstructor(String type, Class[] paramTypes)
  7. getConstructor(String typeString)
  8. getConstructorAccessor(Class enumClass, Class[] additionalParameterTypes)
  9. getConstructorCalls(Class aClass)