Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

Groovy conditional statement


May 14, 2021 Groovy



A conditional declaration requires the program to specify one or more conditions to judge, one or more statements to be executed if the condition is determined to be true, and another statement to execute if the condition is determined to be false.

Serial number Statements and descriptions
1 If statement

The general work of this statement is to first calculate a condition in the if statement. If the condition is true, it then executes the statement.

2 If / else statement

The general work of this statement is to first calculate a condition in the if statement. op. f the condition is false, execute the statement in the else statement block and exit the loop.

3 Nested if statements

i Sometimes multiple if statements need to be embedded inside each other.

4 Switch statement

Sometimes, nested if-else statements are so common and frequently used that an easier statement, called a switch statement, is designed.

5 Nested switch statements

Switch can also be nested on multiple layers.