For-each over Accounts
A for-each loop walks every item in a List in order, with no index to manage: for (Account acct : accounts) { ...
Your task
Loop over three Accounts and print each name, then loop safely over an empty List and a null List.
List<Account> accounts = new List<Account>{
new Account(Name = 'Cedar Labs'),
new Account(Name = 'Northstar Co'),
new Account(Name = 'Bluebird Goods')
};
Integer visitedCount = 0;
List<Account> emptyAccounts = new List<Account>();
Integer emptyCount = 0;
List<Account> missingAccounts = null;
Integer nullCount = 0;Requirements
Visited: Cedar Labsand the other two names should be printed in orderVisited count: 3should be printedEmpty count: 0should be printedNull count: 0should be printed- for-each loop should be used over
accounts - for-each loop should be used over
emptyAccounts missingAccounts != nullshould be checkedVisited: Cedar Labsshould be built at runtime