Here you can find the source of newInstance(String className, Object[] args)
public static Object newInstance(String className, Object[] args) throws Exception
//package com.java2s; //License from project: Open Source License import java.lang.reflect.Constructor; public class Main { public static Object newInstance(String className, Object[] args) throws Exception { Class newoneClass = Class.forName(className); Class[] argsClass = new Class[args.length]; for (int i = 0, j = args.length; i < j; i++) { argsClass[i] = args[i].getClass(); }//from w w w .j a va 2 s .c om Constructor cons = newoneClass.getConstructor(argsClass); return cons.newInstance(args); } }