-
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
Mastering Email Deliverability in Salesforce Marketing Cloud
In today’s world of digital marketing, an email's journey from your campaign to your subscriber's inbox is an important aspect that has a bearing on…
Guide to Salesforce Service Cloud Implementation
Delivering exceptional customer service is no longer optional. Customers expect quick responses, personalized interactions, and support across multiple channels. This is where Salesforce Service Cloud…
Getting Into Salesforce? Tips and Tricks You Need to Get your Hands on!
Are you considering getting into Salesforce? Maybe you are thinking of a new career path, your work is migrating to Salesforce, or you just want…
Popular Salesforce Videos
GS DevOps Mate: Your Free Flexible Toolkit for Faster & Smoother Salesforce Deployments
Our webinar about GS DevOps Mate: A free, open-source, CI/CD platform agnostic toolkit! Our host is Rohan Gore a Technical Architect here at Groundswell who…
What is Workflow Rule in Salesforce | Salesforce Interview Questions and Answers
What is Workflow Rule in Salesforce | Salesforce Interview Questions and Answers
Salesforce Tower San Francisco Virtual Community Tour
Wherever you are around the world, join us for a virtual tour of Salesforce Tower San Francisco, our global headquarters. Together, we’ll take a walk…