IN THIS VIDEO WE ARE GOING TO DISCUSS ABOUT THE CONDITIONAL STATEMENTS IN JAVA . AFTER WATCHING VIDEO IF YOU HAD ANY PROBLEMS/QUERY RELATED TO THIS TOPIC POST IT IN COOMMENTS .
***********************
The if Statement
Use the if statement to specify a block of Java code to be executed if a condition is true.
Syntax
if (condition) {
// block of code to be executed if the condition is true
}
Note that if is in lowercase letters. Uppercase letters (If or IF) will generate an error.
***********************
The else Statement
Use the else statement to specify a block of code to be executed if the condition is false.
Syntax
if (condition) {
// block of code to be executed if the condition is true
} else {
// block of code to be executed if the condition is false
}
Note that else is in lowercase letters. Uppercase letters (Else or ELSE) will generate an error.
**************************
The else if Statement
Use the else if statement to specify a new condition if the first condition is false.
Syntax
if (condition1) {
// block of code to be executed if condition1 is true
} else if (condition2) {
// block of code to be executed if the condition1 is false and condition2 is true
} else {
// block of code to be executed if the condition1 is false and condition2 is false
}
***********************
Nested If..else statement
When an if else statement is present inside the body of another “if” or “else” then this is called nested if else.
Syntax of Nested if else statement:
if(condition) {
//Nested if else inside the body of "if"
if(condition2) {
//Statements inside the body of nested "if"
}
else {
//Statements inside the body of nested "else"
}
}
else {
//Statements inside the body of "else"
}
#java #python #programming #tutorial #computerscience #conditionalstatements #ifelse #subscribe #tecq #c++ #class12 #javatutorial
コメント