Java Class New Instance newInstance(Class cmdClass)

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

Description

new Instance

License

Apache License

Declaration

public static Object newInstance(Class cmdClass) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.lang.reflect.Constructor;

public class Main {
    public static Object newInstance(Class cmdClass) {
        return newInstance(cmdClass, null, null);
    }//from  ww  w  .j a  v  a 2 s .  c o  m

    public static Object newInstance(Class cmdClass, Class[] parameterTypes, Object[] parameters) {
        try {
            Constructor con = cmdClass.getConstructor(parameterTypes);
            Object instance = con.newInstance(parameters);
            return instance;
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return null;
    }
}

Related

  1. newInstance(Class clazz)
  2. newInstance(Class clazz)
  3. newInstance(Class clazzName)
  4. newInstance(Class cls)
  5. newInstance(Class cls)
  6. newInstance(Class constructorClass, Object[] parameters)
  7. newInstance(Class klass)
  8. newInstance(Class targetClass)
  9. newInstance(Class cl, Object[] args)