Java Class New Instance newInstance(Class klass)

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

Description

new Instance

License

Open Source License

Declaration

public static Object newInstance(Class klass) 

Method Source Code

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

public class Main {
    public static Object newInstance(Class klass) {
        try {//from  w w w . jav a  2 s .  c om
            return klass.newInstance();
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    public static Object newInstance(String klassname) {
        return newInstance(classForName(klassname));
    }

    public static Class classForName(String name) {
        try {
            return Class.forName(name);
        } catch (ClassNotFoundException ex) {
            throw new RuntimeException(ex);
        }
    }
}

Related

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