Welcome to my blog

I have been working with Salesforce for quite a while, so don’t hesitate to contact me if you have any questions or want some advice.

s f

Follow Us


 . Apex  . APEX – LOOPS
Learn in Detail About Salesforce Apex Loops And Types of Loops


Learn in Detail About Salesforce Apex Loops And Types of Loops

Loops are used when a particular piece of code should be repeated with the desired number of iteration. Apex supports the standard traditional for loop as well as other advanced types of Loops. In this chapter, we will discuss in detail about the Loops in Apex.

A loop statement allows us to execute a statement or group of statements multiple times and following is the general from of a loop statement in most of the programming languages −

The following tables lists down the different Loops that handle looping requirements in Apex Programming language. Click the following links to check their detail.

Types of Loops:-

  • For Loop
  • While Loop
  • Do-While Loop

For Loop:-

for loop is a repetition control structure that allows you to efficiently write a loop that needs to execute a specific number of times. Consider a business case wherein, we are required to process or update the 100 records in one time. This is where the Loop syntax helps and makes work easier.


for (variable : list_or_set) { code_block }

Do-While Loop:-

Unlike the for and the while loops which test the loop condition at the top of the loop, the do…while loop checks its condition at the bottom of the loop.

A do…while loop is similar to a while loop, except that a do…while loop is guaranteed to execute at least one time.


do { code_to_execute } while (Boolean_condition);


  • zoritoler imol

    July 1, 2023

    Hi there, You have performed an excellent job. I’ll definitely digg it and individually recommend to my friends. I’m confident they’ll be benefited from this site.


Post a Comment