Java Class New Instance newInstance(Class type)

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

Description

A helper method to create a new instance of a type using the default constructor arguments.

License

Apache License

Declaration

public static <T> T newInstance(Class<T> type) 

Method Source Code

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

public class Main {
    /**/*from www  . j a  v a 2 s  .co m*/
     * A helper method to create a new instance of a type using the default
     * constructor arguments.
     */
    public static <T> T newInstance(Class<T> type) {
        try {
            return type.newInstance();
        } catch (InstantiationException e) {
            throw new RuntimeException(e);
        } catch (IllegalAccessException e) {
            throw new RuntimeException(e);
        }
    }
}

Related

  1. newInstance(Class theClass, String className)
  2. newInstance(Class theCls)
  3. newInstance(Class type)
  4. newInstance(Class type)
  5. newInstance(Class type)
  6. newInstance(Class type)
  7. newInstance(Class type)
  8. newInstance(Class type)
  9. newInstance(Class type)