Here you can find the source of newInstance(Class
static public <T> T newInstance(Class<T> clazz)
//package com.java2s; //License from project: Open Source License import java.lang.reflect.Constructor; public class Main { static public <T> T newInstance(Class<T> clazz) { Constructor<T> ctor = null; try {// w w w . j a va 2 s .co m ctor = clazz.getDeclaredConstructor(new Class<?>[0]); ctor.setAccessible(true); T o = ctor.newInstance(new Object[0]); return o; } catch (Throwable t) { return null; } finally { if (ctor != null) { ctor.setAccessible(false); } } } }