Here you can find the source of newInstance(Class
public static <T> T newInstance(Class<T> clazz, Object... params) throws SQLException
//package com.java2s; //License from project: Apache License import java.lang.reflect.Constructor; import java.sql.SQLException; public class Main { public static <T> T newInstance(Class<T> clazz, Object... params) throws SQLException { try {//w w w . j a v a 2 s .c o m if (params == null || params.length == 0) { return clazz.newInstance(); } else { for (Constructor<?> ctor : clazz.getConstructors()) { if (ctor.getParameterTypes().length == params.length) { int paramIndex = 0; for (Class<?> paramType : ctor.getParameterTypes()) { if (!paramType.isInstance(params[paramIndex])) { break; } paramIndex++; } if (paramIndex == params.length) { return clazz.cast(ctor.newInstance(params)); } } } throw new SQLException("Constructor not found for " + clazz); } } catch (ReflectiveOperationException reflectiveOperationException) { throw new SQLException(reflectiveOperationException); } } }