- Introduction to if-else statement in java in Hindi
- if statement in java in Hindi
- if-else statement in java in Hindi
- if-else-if ladder in java
- nested if statement in java

Introduction to if-else statement in java
जावा if statement का उपयोग condition को test करने के लिए किया जाता है। यह boolean condition की जाँच करता है: true या false. Java में if स्टेटमेंट के विभिन्न प्रकार हैं।
- if statement
- if-else statement
- if-else-if ladder
- nested if statement
Java if Statement
जावा if statement, condition test करता है। यदि स्थिति true है , तो यह if ब्लॉक को निष्पादित करता है।
Syntax:
if(condition){
//code to be executed
}
उदाहरण:
//Java Program to demonstate the use of if statement.
public class IfExample {
public static void main(String[] args) {
//defining an 'age' variable
int age=20;
//checking the age
if(age>18){
System.out.print("Age is greater than 18");
}
}
}
आउटपुट:
Age is greater than 18
Java if-else Statement
जावा if-else statement भी condition का परीक्षण करता है। यदि condition true है तो यह if ब्लॉक को निष्पादित करता है अन्यथा else ब्लॉक को निष्पादित किया जाता है।
Syntax:
if(condition){
//code if condition is true
}else{
//code if condition is false
}
उदाहरण:
//A Java Program to demonstrate the use of if-else statement.
//It is a program of odd and even number.
public class IfElseExample {
public static void main(String[] args) {
//defining a variable
int number=13;
//Check if the number is divisible by 2 or not
if(number%2==0){
System.out.println("even number");
}else{
System.out.println("odd number");
}
}
}
आउटपुट:
odd number
Java if-else-if ladder Statement
if-else-if ladder statement एक condition को multiple statement से निष्पादित करता है।
syntax:
if(condition1){
//code to be executed if condition1 is true
}else if(condition2){
//code to be executed if condition2 is true
}
else if(condition3){
//code to be executed if condition3 is true
}
...
else{
//code to be executed if all the conditions are false
}

Java Nested if Statement
Nested if statement एक if block का प्रतिनिधित्व (representation) एक और if block के भीतर करता है। यहाँ, inner if block condition केवल तभी निष्पादित होती है जब outer if block की condition true है।
syntax:
if(condition){
//code to be executed
if(condition){
//code to be executed
}
}
