Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
I'm looking to dynamically instantiate a class by its name. How can I do that in Apex? I thought about a factory method with a series of if-else statements, but am not satisfied with that as it isn't a general solution.
It seems something like that is possible with:
System.Type objType = Type.forName(objName);
Object obj = objType.newInstance();
Required, but never shown