📜  Groovy-决策制定

📅  最后修改于: 2020-11-04 06:36:43             🧑  作者: Mango


决策结构要求程序员指定一个或多个要由程序评估或测试的条件,以及确定条件为true时要执行的一个或多个语句,如果条件为true则可以选择要执行的其他语句。条件被确定为错误

Sr.No. Statements & Description
1 if Statement

The general working of this statement is that first a condition is evaluated in the if statement. If the condition is true, it then executes the statements.

2 if/else Statement

The general working of this statement is that first a condition is evaluated in the if statement. If the condition is true it then executes the statements thereafter and stops before the else condition and exits out of the loop. If the condition is false it then executes the statements in the else statement block and then exits the loop.

3 Nested If Statement

Sometimes there is a requirement to have multiple if statement embedded inside of each other.

4 Switch Statement

Sometimes the nested if-else statement is so common and is used so often that an easier statement was designed called the switch statement.

5 Nested Switch Statement

It is also possible to have a nested set of switch statements.