📜  Apex-决策制定

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


决策结构要求程序员指定一个或多个要由程序评估或测试的条件,如果确定条件为真,则指定要执行的一个或多个语句,如果条件为真,则可选地指定要执行的其他语句。条件确定为假。

在本章中,我们将研究Apex中决策和条件语句的基本和高级结构。无论是否满足某些条件,决策对于控制执行流程都是必要的。以下是大多数编程语言中常见的典型决策结构的一般形式

做决定

Sr.No. Statement & Description
1 if statement

An if statement consists of a Boolean expression followed by one or more statements.

2 if…else statement

An if statement can be followed by an optional else statement, which executes when the Boolean expression is false.

3 if…elseif…else statement

An if statement can be followed by an optional else if…else statement, which is very useful to test various conditions using single if…else if statement.

4 nested if statement

You can use one if or else if statement inside another if or else if statement(s).