Decision Making in GroovyIn groovy, decision-making is used to check the condition and execute the statements. if the condition is true then the true block statement is executed and if the condition is false then the false block is executed. If statementIn groovy, if statement is used when we have only one condition. In if statement there is only true block. If the condition is true then the true block is executed. There is no false or else block in this statement. Syntax:Flow chart: Example 1:Output: Example 2:Output: If else statementIn groovy, if else statement is used when only one condition. In if else statement we have a true as well as false or we can say else block. If the condition is true then the true block is executed otherwise else block is executed. Syntax:Flow chart: Example 3:Output: Example 4:Output: Nested If StatementIn groovy, Nested if statement is used when we have more than one condition. Syntax:Flow chart: Example 5:Output: Switch StatementIn groovy, a switch is a multiway branch statement. It provides an easy way to execute different parts of the code which are based on the value of the expression. Syntax:Flow chart: Example 6:Output: Next TopicGroovy - Strings |