Here you can find the source of newInstance(Class
Parameter | Description |
---|---|
cl | The class object. |
T | The class type. |
public static <T> T newInstance(Class<T> cl)
//package com.java2s; //License from project: Open Source License public class Main { /**//from w w w . j a v a2 s . c o m * Create a new instance of a class * * @param cl The class object. * @param <T> The class type. * @return New class instance. */ public static <T> T newInstance(Class<T> cl) { try { return cl.newInstance(); } catch (InstantiationException | IllegalAccessException e) { throw new RuntimeException(e); } } }