Apex Class
public class myOuterClass{
public class myInnerClass{
public void show() {
System.debug('Hello');
}
}
}
ApexCode
To call a method of your inner class, use the following code:
myOuterClass.myInnerClass innObj = new myOuterClass.myInnerClass();
innObj.show();
Consideration
- Access modifiers:
- You must use one of the access modifiers (such as public or global) in the declaration of a top-level class.
- You do not have to use an access modifier in the declaration of an inner class.
- Optional definition modifiers (such as virtual, abstract, and so on)
- Required: The keyword class followed by the name of the class
- Optional extensions and/or implementations