CONDITIONAL STATEMENTS
A conditional statement consists of a condition and a task. When the condition is true, the application performs the task. The condition portion of a conditional statement is also called an expression.
There are four types of conditional statements in java :
- If Condition.
- If else condition.
- If else If condition.
- Nested If condition.
- if(condition){
- //code to be executed
- }
If else Condition: The Java if statement is used to test the condition. It checks boolean condition: true or false. There are various types of if statement in Java.
- if(condition){
- //code if condition is true
- }else{
- //code if condition is false
- }
If Else If Conditions: The if-else-if ladder statement executes one condition from multiple statements.
Nested If : The nested if statement represents the if block within another if block. Here, the inner if block condition executes only when outer if block condition is true.
- if(condition){
- //code to be executed
- if(condition){
- //code to be executed
- }
- }
Comments
Post a Comment
THANK YOU FOR COMMENTING !
PLEASE SUBSCRIBE TO OUR WEBSITE FOR LATEST UPDATES