Apex Variable Declaration – Apex Data Types List.

In our last Salesforce Developer Tutorial we have learned about Apex Basics and Apex language building blocks. In this Salesforce Apex Tutorial we are going to learn about apex variables, Apex Variable declaration, Apex Data types.

Apex variables and Variable Declaration.

As already we discussed about Apex language that is a strongly typed language so we have to declare  all variable before they are referenced in Apex coding. As general when we declare variables we have to declare data type followed by variable name.

Example :- Integer i; (Integer = Data Type, i = variable name).

  • We should not declare variable name with symbols, numeric values.
  • Variable names should not contained with underscore(_) extension.
  • We should not use apex reserve words.
  • We can use both lower case and upper case letters since they are not case sensitive.

Apex Data Types list.

Data TypeValid Values
StringZero and Unicode characters
BooleanTrue / False
DateDate
DateTimeDate & Time
TimeTime
Integer-2,147,483,648 to 2,147483,647
Long -263 to 263-1
Decimalsigned number
Double -263 to 263-1
Blobbinary data value.
ID18 characters
Object—–