Conditional Statements In Java
This is your Resource Creation Editor Tool
Control statements in java
These control statements control the flow of execution of the application. These statements are takes conditional statements which will return boolean value.
- if statement
- nested if statement
- if-else statement
- if-else-if ladder
if statement: if statement will check wither the given condition true or false, it will allow the controller to get into the if block if the condition evaluate to true only.
In the above code snippet line no 8 will execute if the age is greater than 18 only.
Nested if statement: If the if statement having one more if statement in it the we can call it as nested if statement.
In the above code snippet, the line 10 will execute if both conditions are true.
if-else statement: If the if condition follows with one else block then we call it as if-else statement. In this approach, if the condition false then the controller will execute the else block statements.
In the above code snippet, if the age less than 18 then the condition false, then the controller will execute the else block (i.e line no 9 will be executed).
if-else-if ladder: If the requirement needs multiple conditions to check then will go for if-else-if ladder, in this we will have multiple else-if blocks.
The below snippet will depicts the if-else-if ladder.
- HTML Introduction
- HTML CSS Basics
- HTML Elements
- Headings HTML
- Images In HTML
- HTML List
- HTML Head And Metadata
- HTML Styles
- HTML Tables
- Constructor Overloading