publicclassAccountNameLogger{publicstaticvoidlogAccountsWithNameStartingA(){List<Account> accounts =[SELECT Name FROM Account WHERE Name LIKE'A%'];for(Account acc : accounts){System.debug('Account Starting with A: '+ acc.Name);}}}
List<Account> accounts =[SELECT Name FROM Account WHERE Name LIKE'A%'];
データの処理と出力:
このforループは、取得した取引先の名前を1つずつ処理するためのものです。
System.debug('Account Starting with A: ' + acc.Name);この行は、現在の取引先の名前をコンソールに出力するためのものです。
for(Account acc : accounts){System.debug('Account Starting with A: '+ acc.Name);}
解答例(コメント付き)
publicclassAccountNameLogger{publicstaticvoidlogAccountsWithNameStartingA(){// "A"で始まる取引先の名前を取得List<Account> accounts =[SELECT Name FROM Account WHERE Name LIKE'A%'];// 取得した取引先の名前をコンソールに出力for(Account acc : accounts){System.debug('Account Starting with A: '+ acc.Name);}}}
コメント