-
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
4 Ways Salesforce Can Help Enhance Your Field Work
Are you a company that provides field service? If so, you understand how important it is to offer the best quality in your work. After…
7 Different Types of Object Relations in Salesforce
Understanding Data Relationships between objects in Salesforce can be challenging. There can be a situation in a company where you have to create a bespoke…
Popular Salesforce Videos
Manage Record Access and Visibility in Salesforce
Watch this video to learn all about managing record access and visibility in Salesforce. Do let us know in the comment section if you have…
Salesforce Diagram | Salesforce Diagramming Framework
Diagrams help drive key project decisions, align delivery teams, and help everyone understand where you’re going and what’s been done. Consistent, easy-to-understand diagrams are a…
Automate Your App With and Without Code | Salesforce Developer Tutorial
In this video, you will learn how you can automate your business process with and without code. This video teaches you how to use a…