Here you can find the source of newInstance(Class
public static <T> T newInstance(Class<T> klass)
//package com.java2s; //License from project: Open Source License import java.lang.reflect.Constructor; public class Main { public static <T> T newInstance(Class<T> klass) { T t = null;/*from w w w .j a v a 2 s . com*/ try { Constructor<T> constructor = klass.getDeclaredConstructor(); if (constructor != null) { constructor.setAccessible(true); t = constructor.newInstance(); } } catch (Exception e) { e.printStackTrace(); } return t; } }