Sunday, 8 January 2023

Apex List or Set Iteration for Loops | For Each Loop | Enhanced or Range Based For Loop | Salesforce

                 In this post, we will see Apex List or Set Iteration for Loops | For Each Loop | Enhanced or Range Based For Loop | Salesforce 


Program Code: (Anonymous Window)

/*Array*/

integer[] myarr=new integer[]{20,10,33,33,31};

string[] strarr=new string[]{'a','b','c','d','e'}; 

    

/*list*/

list<integer> mylist=new list<integer>{20,10,33,33,31}; 

    

/*set*/    

set<integer> myset=new set<integer>{20,10,31,33,31};    

    

for(integer i : myset)  

{

    system.debug('Value of i='+i);

}

    

No comments:

Post a Comment