Here you can find the source of newInstance(Class
public static <T> T newInstance(Class<T> clazz)
//package com.java2s; public class Main { @SuppressWarnings("unchecked") public static <T> T newInstance(String clazz) { try {/*from w w w . j ava2 s .c om*/ return (T) Class.forName(clazz).newInstance(); } catch (Exception e) { throw new RuntimeException("Instance class " + clazz + " error!"); } } public static <T> T newInstance(Class<T> clazz) { try { return (T) clazz.newInstance(); } catch (Exception e) { throw new RuntimeException("Instance class " + clazz + " error!"); } } public static <T> T newInstance(Class<T> clazz, Object... params) { if (null == params || 0 == params.length) { return newInstance(clazz); } try { return clazz.getDeclaredConstructor(getClasses(params)).newInstance(params); } catch (Exception e) { throw new RuntimeException("Instance class " + clazz + " error!", e); } } public static Class<?>[] getClasses(Object... objects) { Class<?>[] classes = new Class<?>[objects.length]; for (int i = 0; i < objects.length; i++) { classes[i] = objects[i].getClass(); } return classes; } }