Loops
Apex supports five types of procedural loops.
These types of procedural loops are supported:
do
{
statement
}
while
(
Boolean_condition
);
while
(
Boolean_condition
)
statement
;
for
(
initialization
;
Boolean_exit_condition
;
increment
)
statement
;
for
(
variable
:
array_or_set
)
statement
;
for
(
variable
: [
inline_soql_query
])
statement
;
All loops allow for loop control structures:
break
;
exits the entire loop
continue
;
skips to the next iteration of the loop
Do-While Loops
While Loops
For Loops