function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
CCCBBBAAACCCBBBAAA 

First-class classes?

I do not see that Apex exposes a class data type. Is this correct? Is there no way to assign a class to a variable in Apex? My research thus far indicates that Apex does not support any sort of metaprogramming, not even string evaluation. It seems most issues surrounding this question are centered on standard/custom object reflection, but I am seeking a way to pass classes around such that `Class myClass = SomeApexClass` can be instantiated with `new myClass(args...)`.

Best Answer chosen by Admin (Salesforce Developers) 
aaron-oaaron-o

You can certainly do that, although I'm not sure you can specify arguments to the constructor this way.  The class probably must have a public no-arg constructor for this to work.

 

See here: http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_methods_system_type.htm