Sunday 8 January 2023

Looping Statements in Apex | Loop Structure in Apex in Salesforce | Apex Control Structures Part 4

                  In this post, we will see Looping Statements in Apex | Loop Structure in Apex in Salesforce | Apex Control Structures Part 4 


Program Code: (Anonymous Window)

/* To print squares of 0 to 4 */


/*

for(integer i=0; i<5; i++)

{

system.debug('Square of '+i+'='+i*i);

}

*/


/*

integer i=0;

while(i<5)

{

    system.debug('Square of '+i+'='+i*i);

    i++;

}

*/


integer i=0;

do

{

    system.debug('Square of '+i+'='+i*i);

    i++;

}

while(i<5);


No comments:

Post a Comment