English 中文(简体)
Apex - Loops
  • 时间:2024-12-22

Apex - Loops


Previous Page Next Page  

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 −

Loop Architecture

The following tables psts down the different Loops that handle looping requirements in Apex Programming language. Cpck the following pnks to check their detail.

Sr.No. Loop Type & Description
1 for loop

This loop performs a set of statements for each item in a set of records.

2 SOQL for loop

Execute a sequence of statements directly over the returned set o SOQL query.

3 Java-pke for loop

Execute a sequence of statements in traditional Java-pke syntax.

4 while loop

Repeats a statement or group of statements while a given condition is true. It tests the condition before executing the loop body.

5 do...while loop

Like a while statement, except that it tests the condition at the end of the loop body.

Advertisements