Wednesday, January 25, 2017

Apex - Loops

Loops are used when a particular piece of code should be repeated with desired number of iteration. Apex supports the standard traditional for loop as well as other advanced types of Loops. Lets have a more detailed look on 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
Apex programming language provides following kinds of loop to handle looping requirements. Click the following links to check their detail.
Loop Type Description
for loop This loop performs a set of statements for each item in a set of records.
SOQL for loop Execute a sequence of statements directly over the returned set of SOQL query.
Java-like for loop Execute a sequence of statements in traditional Java-like syntax.
while loop Repeats a statement or group of statements while a given condition is true. It tests the condition before executing the loop body.
do...while loop Like a while statement, except that it tests the condition at the end of the loop body.

No comments:

Post a Comment