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
rameshkunta20081.3929473256963662E12rameshkunta20081.3929473256963662E12 

for(student__c st:st1) what it really does?,does records flow from student__c to st1? please help me with explanation thanks.

Best Answer chosen by rameshkunta20081.3929473256963662E12
Sonam_SFDCSonam_SFDC
It is kind of defining the number of iterations the for loop has to go on for:

You are passing the values present in st1(being a list of records) to st object instance one at a time when the for loop is executed.

All Answers

Sonam_SFDCSonam_SFDC
It is kind of defining the number of iterations the for loop has to go on for:

You are passing the values present in st1(being a list of records) to st object instance one at a time when the for loop is executed.
This was selected as the best answer
nbknbk
if you want to update bunch of the records with specific fields, you can use this. Example scneario is below to update account name records with testname.

list<account> lstaccount = [select id,name from account limit 100];
list<account> lstadd = new list<account>();
for(account acc:lstaccount) //lstaccount have first 100 records from the account object and iterate 1 by one
{
    acc.name = 'testaccount-updated';
    lstadd.add(acc);
}
update lstadd;

rameshkunta20081.3929473256963662E12rameshkunta20081.3929473256963662E12
thank you , superb explained