Call: IN +91 7013283324 | +91 9347854179
(Click on WhatsApp Chat button)
Call: US +1 (415) 529-7271

Salesforce Apex Tutorial – Chapter 5: Apex Variables

Home  >>  Salesforce Apex Tutorial  >>  Salesforce Apex Tutorial – Chapter 5: Apex Variables

Salesforce Apex Tutorial – Chapter 5: Apex Variables

On October 4, 2021, Posted by , In Salesforce Apex Tutorial, With Comments Off on Salesforce Apex Tutorial – Chapter 5: Apex Variables

A variable is a named value holder in memory. An apex variable is defined as a combination of the data type, identifier, and an optional Initializer. The identifier is the name chosen for a variable. The identifier should start with an alphabet or an underscore and it can be of any length.

You can read the previous article Salesforce Apex Tutorial – Chapter 4: Data Types In Apex and previous one Salesforce Apex Tutorial – Chapter 6: Apex Strings.

The declaration of variables in Apex is quite similar to java. Following is the syntax to declare an apex variable:

type identifier = value;

Below are a few examples of apex variables.

String name = ‘Test’; // String variable declarationBoolean boolValue = True; // Boolean variable declarationInteger intValue= 10; // Integer variable declarationDecimal i = 2.5; //decimal variable declaration

Following are the features of apex variables:

  • Apex variables can be defined at any point in the code block.
  • Apex variables are case insensitive.
  • Apex variables are initialized to null if no other value is assigned to the apex variable during declaration.
  • A variable defined in a method has scope within the method only.
Comments are closed.