Here you can find the source of newInstance(Type type)
Parameter | Description |
---|---|
Object | a parameter |
public static Object newInstance(Type type)
//package com.java2s; //License from project: Open Source License import java.lang.reflect.Type; public class Main { /**/*from w w w .j a v a 2 s . c o m*/ * Creates a new instance of the type from his type name. * The class is instantiated as if by a new expression with an empty argument list * * @param Object * @return Instance of class represented by type name, if the type is not instanceable, returns null */ public static Object newInstance(Type type) { try { return Class.forName(type.toString().substring(0, type.toString().indexOf('@'))).newInstance(); } catch (Throwable e) { } return null; } }