You need to sign in to do that
Don't have an account?

Class instantiation in anonymous block
I am running below code in anonymous block and i get some weird 'internl error'
cannot figure out why .I am new to apex.please help
public class abcd
{public void m1()
{
system.debug('hi');
}
}
abcd objec = new abcd();
objec.m1();
1) Anonymous block: Not at all (sorry)
2) Apex Class (like the thing starting with 01p):
a) You can obviously have the top level class... This is what determines the name of the Apex Class.
b) Inner class: You can have a class definition inside your Apex Class. You CANNOT, however, create yet another layer if class inside an inside class... only one layer of nesting.
3) Apex Trigger
a) Inner class: Since you are already in a sort of code container (a trigger), you can only make one level of classes within a trigger.
Not sure how many classes you can define within a trigger or class, but at that point, especially within a trigger (or an anonymous block if it WERE possible), I might ask myself why I don't make this its own Apex Class, or break several inner classes out into more topic specific Apex Classes with less inner classes each.