Java Class New Instance newInstance(Class clazzName)

Here you can find the source of newInstance(Class clazzName)

Description

new Instance

License

Open Source License

Declaration

public static final Object newInstance(Class clazzName)
        throws ClassNotFoundException, IllegalAccessException, InstantiationException 

Method Source Code

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

import java.lang.reflect.InvocationTargetException;

public class Main {

    public static final Object newInstance(String clazzName)
            throws ClassNotFoundException, IllegalAccessException, InstantiationException {
        return Class.forName(clazzName).newInstance();
    }/* w w w.  ja  va2 s.  c om*/

    public static final Object newInstance(Class clazzName)
            throws ClassNotFoundException, IllegalAccessException, InstantiationException {
        return clazzName.newInstance();
    }

    public static final Object newInstance(String clazzName, Class[] paramsType, Object[] constrArgs)
            throws InvocationTargetException, IllegalArgumentException, IllegalAccessException,
            InstantiationException, SecurityException, NoSuchMethodException, ClassNotFoundException {
        return newInstance(Class.forName(clazzName), paramsType, constrArgs);
    }

    public static final Object newInstance(Class clazzName, Class[] paramTypes, Object[] constrArgs)
            throws InvocationTargetException, IllegalArgumentException, IllegalAccessException,
            InstantiationException, SecurityException, NoSuchMethodException {
        return clazzName.getConstructor(paramTypes).newInstance(constrArgs);
    }
}

Related

  1. newInstance()
  2. newInstance(Class clazz)
  3. newInstance(Class clazz)
  4. newInstance(Class clazz)
  5. newInstance(Class clazz)
  6. newInstance(Class cls)
  7. newInstance(Class cls)
  8. newInstance(Class cmdClass)
  9. newInstance(Class constructorClass, Object[] parameters)