Possible Duplicate:
Cast via reflection and use of Class.cast()
I have a question related to java programming. I want to have the ability to choose the casting type through a string parameter passed to the function. As you see there is a main class which have to be casted to a sub type. These subtype should be specified by the user. How we can do that ?
public void casting(String subClassCast)
{
MainClass mainClass = (subClassCast) MainClassFactory.get();
}