Groovy – Decision Making

  • Post author:
  • Post category:Groovy
  • Post comments:0 Comments
Decision-making

Decision-making structures require that the programmer specify one or more conditions to be evaluated or tested by the program, along with a statement or statements to be executed if the condition is determined to be true, and optionally, other statements to be executed if the condition is determined to be false.

Sr.No.Statements & Description
1if 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.
2if/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.
3Nested If Statement
Sometimes there is a requirement to have multiple if statement embedded inside of each other.
4Switch 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.
5Nested Switch Statement
It is also possible to have a nested set of switch statements.

Next Topic:-Click Here

Leave a Reply