Can I determine the class name of an object instance at run-time?

I’m looking for a way to get the name of an object instance at run-time. Is it possible to to determine the class name (as a string) of an instance? i.e. is there an Apex equivalent of the Java myInstance.getClass().getName() or any tricks to achieve just that?


instanceOf verifies at runtime whether an object is actually an instance of a class…but you would have to write the conditions to check for them all. Also getSObjectType will describe an sObject.

Source : Link , Question Author : Phil Hawthorn , Answer Author : tomlogic

Leave a Comment