Apex supports the three standard types of loops for implementing repeated actions: Do-while, While, and For loops.
A Do-while loop repeatedly executes a set of code statements. The syntax for the loop is as follows:
do { code_block; } while (Boolean_condition);
The code within the curly braces executes and then the condition is evaluated. A Do-while loop always executes at least once.
A While loop is like a do-while loop, except that the while condition is evaluated before any of the statements in the code are executed. Because of this, the code in a While loop might not be executed at all. The syntax for the While loop is as follows:
while (Boolean_condition) { code_block; };
3.144.114.85