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
AlecSAlecS 

Dynamic variables

Hello,

 

I want to assign values to variables on the fly. For example, I have a variable called, YearXDate. X is a number from 1 to n. I want to assign values to YearXDate while in a loop where loop variable is from 1 to n. How do I do that?

 

Thanks!

Cloud CredenceCloud Credence

Hi,

 

I think you cannot create variable dynamically like that in Apex.

 

You have to use Lists to achieve the same.

 

Please refer to Apex documentation regarding lists.