O'Reilly logo

Development with the Force.com Platform: Building Business Applications in the Cloud, Third Edition by Jason Ouellette

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Variables

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.

Variable Declaration

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.

Listing 4.2 Variable Declaration

Integer i;

The variable 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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required