Java Class New Instance newInstance(String className)

Here you can find the source of newInstance(String className)

Description

new Instance

License

Open Source License

Declaration

public static Object newInstance(String className)
            throws ClassNotFoundException, IllegalAccessException, InstantiationException 

Method Source Code

//package com.java2s;

public class Main {
    public static Object newInstance(String className)
            throws ClassNotFoundException, IllegalAccessException, InstantiationException {
        Object object = null;//ww  w.  j a  va  2 s .  c o m
        try {
            object = (Object) Class.forName(className).newInstance();
        } catch (ClassNotFoundException e) {
            ClassLoader cl = Thread.currentThread().getContextClassLoader();
            object = (Object) cl.loadClass(className).newInstance();
        }
        return object;
    }
}

Related

  1. newInstance(String className)
  2. newInstance(String className)
  3. newInstance(String className)
  4. newInstance(String className)
  5. newInstance(String className)
  6. newInstance(String className)
  7. newInstance(String className)
  8. newInstance(String className)
  9. newInstance(String className)