-
What is the difference between these two(loop) codes?
Hi All,
What is the difference between these two(loop) codes?
1) List<Account> accountList = new List<Account>();
accountList = [SELECT Id FROM Account];
for(Account a: accountList){
a.Name = 'update';
}
update accountList;2) for(Integer a = 0; a < accountList.size(); a++){
accountList[a].Name = 'update';
}
update accountList;Does for loop and for each loop works differently?
Thanks
Log In to reply.
Popular Salesforce Blogs
Salesforce Data Loss: Is Your Data Correct? How Can UI Contribute?
For a number of years security and safety of data has been the major reason which proved itself to be a hiccup in the path…
Order of Execution in Salesforce - An Explanation
At the point when you spare a record with an addition, update, or upsert articulation, Salesforce plays out the accompanying occasions altogether. Before Salesforce executes…
What is SOQL in Salesforce in 2023? | The Developer Guide
In this Blog we will learn about SOQL in salesforce. What is SOQL? SOQL stands for Salesforce Object Query Language. When we have to perform…
Popular Salesforce Videos
Pardot Marketing Automation Tools Overview Webinar
Are you looking to take your Salesforce Marketing Automation to the next level? Learn how to build successful lead nurturing campaigns that empower your sales team…
Learn About How to Set Profiles in Salesforce?
Learn about Profiles in Salesforce and types of profiles, Standard and Custom Profiles. Watch this video and do let us know in the comment section…
Summer Internship | Career with Salesforce
This Summer, dive into the ocean of Salesforce with S2 Labs Apply for the much-awaited S2 Labs Summer Internship Program and start accelerating your career…