This subsection covers variable declaration, data types, constants and enums, and type conversions. It also provides detail on rounding numbers and converting dates to and from strings, common tasks in business applications.
Apex is a strongly typed language. All variables must be declared before they’re referenced. At minimum, a variable declaration consists of the data type followed by the variable name. For example, Listing 4.2 is a valid statement.
i is declared to be an Integer. Apex does not require variables to be initialized before use, but doing so is good practice. The variable
i initially contains a null value.
Variable names cannot start with ...