Class Variables
To declare a variable, specify the following:
- Optional: Modifiers, such as
publicorfinal, as well asstatic. - Required: The data type of the variable, such as String or Boolean.
- Required: The name of the variable.
- Optional: The value of the variable.
Use the following syntax when defining a variable, where data_type, variable_name, and value are placeholder values:
For example:
In API version 50.0 and later, scope and accessibility rules are enforced on Apex variables, methods, inner classes, and interfaces that are annotated with @namespaceAccessible. For accessibility considerations, see NamespaceAccessible Annotation. For more information on namespace-based visibility, see Namespace-Based Visibility for Apex Classes in Second-Generation Packages.