-
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
Unboxing Salesforce Winter ’20 edition| Accelerate the adoption with Salesforce In-App guidance
Along with numerous global events taking place this winter, Salesforce has also released its much-awaited Winter ’20 edition. And, as always, Salesforce has exceeded the…
Enhancing Salesforce Development with SFDX: Key Strategies and Techniques
In the landscape of Salesforce development, Salesforce DX (SFDX) is a game-changer. More than just a tool, SFDX revolutionizes how developers create, test, and deploy…
How Does Salesforce Marketing Cloud Solve the Marketing Issues of Small Businesses?
With time customer demands are growing, and it becomes an issue for the marketer to maintain the product's branding. This is particularly true for small-scale…
Popular Salesforce Videos
Developer Preview Live - Release Readiness Live, Winter '22 | Salesforce
The Winter ’22 release is packed full of features to help developers solve key business problems fast. Join us to learn from Product Managers and…
Get Started with Salesforce Order Management in Commerce Cloud
This video will give you an overview of Salesforce Order Management and how to get started with implementing and using the application. In this session…
Duplicate Management In Salesforce | Duplicate Rule and Matching Rule
Learn how to work with duplicate rules and duplicate records in Salesforce. This video will cover the following points - 1. Matching Rule (1:20) Get…