📜  Apex-循环

📅  最后修改于: 2020-11-05 03:10:45             🧑  作者: Mango


当特定代码段应以所需的迭代次数进行重复时,将使用循环。 Apex支持传统的for循环标准以及其他高级循环类型。在本章中,我们将详细讨论Apex中的Loops。

循环语句使我们可以多次执行一个语句或一组语句,以下是大多数编程语言中循环语句的概述-

循环架构

下表列出了处理Apex编程语言中循环要求的不同循环。单击以下链接以查看其详细信息。

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-like for loop

Execute a sequence of statements in traditional Java-like 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.