English 中文(简体)
Groovy - Loops
  • 时间:2024-11-05

Groovy - Loops


Previous Page Next Page  

So far, we have seen statements which have been executed one after the other in a sequential manner. Additionally, statements are provided in Groovy to alter the flow of control in a program’s logic. They are then classified into flow of control statements which we will see in detail.

S.No. Statements & Description
1 While Statement

The while statement is executed by first evaluating the condition expression (a Boolean value), and if the result is true, then the statements in the while loop are executed.

2 for Statement

The for statement is used to iterate through a set of values.

3 for-in Statement

The for-in statement is used to iterate through a set of values.

Loop Control Statements

S.No. Statements & Description
1 Break Statement

The break statement is used to alter the flow of control inside loops and switch statements.

2 Continue Statement

The continue statement complements the break statement. Its use is restricted to while and for loops.

Advertisements