You need to use Reflection in Java for any kind of behavior manipulation of this type on runtime. You can try the following code and see if that works (since you did not show any effort, I will not give any code).
Class<?> cls = Class.forName(name);
Object clsInstance = (Object) cls.newInstance();
You can then have the instance of the type. I used the following code to create a new instance of "String" type in Java,
try {
Class classtype = Class.forName("java.lang.String");
Object instance = classtype.newInstance();
if((String)instance != null) {
System.out.println("Object created.");
} else {
System.out.println("Object not created -- or null.");
}
} catch (ClassNotFoundException ex) {
Logger.getLogger(HelloJava.class.getName()).log(Level.SEVERE, null, ex);
} catch (Exception er) {
}
You can create any object, just pass the type of that object to create for Java runtime to build it and then get the instance of that object.
For more on reflection or the Class type in Java, please read:
Class (Java Platform SE 7 )[
^]