Java tutorial
//package com.java2s; import java.lang.reflect.Constructor; public class Main { static public Object newInstance(String className, Object... args) throws Exception { Class<?> newoneClass = Class.forName(className); Class<?>[] argsClass = null; if (args != null && args.length > 0) { argsClass = new Class<?>[args.length]; for (int i = 0, j = args.length; i < j; i++) { argsClass[i] = args[i].getClass(); if (argsClass[i] == Integer.class) { argsClass[i] = int.class; } else if (argsClass[i] == Boolean.class) { argsClass[i] = boolean.class; } } } Constructor<?> cons = newoneClass.getConstructor(argsClass); return cons.newInstance(args); } }