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
mohammed azhar 23mohammed azhar 23 

Create a Integer list which stores the numbers for 1 to 20

ravi soniravi soni

hi @mohammed azhar 23,
Here is a dynmic way to store number into list.
 

list<integer> lstInteger = new list<integer>();

for(integer i=1; i<=20; i++){
lstInteger.add(i);
}
system.debug(lstInteger);
//Output : 1,2,3,4,5,6.....20
 

like this  we can store not only 20 but more than 20 too. you need to change i<=20; this and put any value place of 20 such as 40,100... etc.
don't forget to mark it as best answer.
Thank you