Loops
public class LoopsInApex {
public static void handleForLoops(){
List<String> myCharacters = new List<String>{'Trainer','Mentor','Reader','Investor'};
for(Integer i=0; i<5; i++){
system.debug('Value of i: '+ i);
}
for(String Chars : myCharacters){
system.debug('Chars : '+Chars);
}
Set<Id> myAccIds = new Set<Id>{'001J400000KjIboIAF','0015j000013bijPAAQ'};
for(Id eachAccId : myAccIds){
system.debug('eachAccId: '+eachAccId);
}
Map<Id,String> myAccountInfo = new Map<Id,String>();
myAccountInfo.put('001J400000KjIboIAF','SFDC Learner');
myAccountInfo.put('0015j000013bijPAAQ','Ram Prasad');
for(Id AccId : myAccountInfo.keySet()){
system.debug('AccId : '+ AccId );
system.debug('AccId Name : '+ myAccountInfo.get(AccId) );
}
for(String AccName : myAccountInfo.Values()){
system.debug('AccName : '+ AccName );
}
for(Account acc: [select Id,Name from Account LIMIT 5]){
system.debug(acc.Name);
}
}
}