function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

What is variable and constants in apex what is difference between them

Ranjeet Singh (SFDC Developer)Ranjeet Singh (SFDC Developer)

The main diffrence between variable and Constant.

Variable: Varaible value can be change any time. it cant be fix.


Constant: Constant value can not be change. Constants can be defined using the final keyword, which means that the variable can be assigned at most once, either in the declaration itself, or with a static initializer method if the constant is defined in a class.


How to declare Variable and Constant:


Public Integer fstNumber;



static final Integer fstNumber=10;


static final Integer fstNumber;