// The following code dynamically does // new Dyna().setName("Matt"); // using reflection. // It is quite a production, and is quite slow. String methodName = "setName"; String someData = "Matt"; Class dynaclass = Class.forName( "Dyna" ); // method accepts parameters, define the types in order here as Class[] Class[] classParams = new Class [] { String.class}; // set the method of the class object Method someMethod = dynaclass.getMethod( methodName, classParams ); // pass values to fill parameters of method Object[] arguments = new Object [] { someData }; // invoke method via reflection someMethod.invoke( dynaclass.newInstance(), arguments );