Notes
In Apex, you can use a for-each loop to iterate over a collection of sObjects, such as a list of records retrieved from a query or a list of sObjects passed as a parameter. The for-each loop provides a concise and readable way to iterate through the elements of a collection.
Here's a basic example of using a for-each loop with sObjects:
List<Account> accountList = [SELECT Id, Name FROM Account LIMIT 5];
for (Account acc : accountList) {
System.debug('Account Name: ' + acc.Name);
}
Output:
Bank of America
Honda
Amazon
Toyota
OpenAI
Video
Video does not exists.