-
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

Integrating Salesforce Service Cloud Voice with Amazon Connect: A Step-by-Step Guide
Many users of Salesforce Service Cloud are likely aware of the new AI-driven feature, Service Cloud Voice. Despite the rise of digital communication tools, telephone…

Salesforce Evergreen | Scale Up Your Cloud Productivity With Ease
The trend of Cloud-based services has forever changed the way we develop and deploy applications in the server. In spite of all the benefits that the Salesforce…

Related Records Updation with the Help of Salesforce Flow
Hello all, In this blog, we will get to know how to update records using Salesforce flow. For updating the related object records we can…
Popular Salesforce Videos
Things you can do with Loyalty Management in Salesforce to Create Lifelong Customers
Although keeping customers is not always simple, statistics show that when they are a part of an ongoing customer loyalty management program, they spend 67%…
Apex Performance Tips and Tricks | Salesforce Video Guide
Watch this video to learn all about Apex Performance: • What do we mean by performance? • How do we measure performance? • Loop Performance…
Salesforce Service Cloud: Upload Files During a Live Chat
Chatbots are incredible automation tools that can streamline a variety of business processes. Still, regardless of how much they can accomplish, there are situations where…