Java If-else Statement in Hindi – If-else Statement in Java in Hindi

इस Article में If else Statement in Java in Hindi या Java If else Statement in Hindi के बारे में जानेगे। If else Statement Conditional Statement है। जो की किसी भी Condition को Check करते है। ये Program के बहुत महत्त्वपूर्ण Statement है।
Java If else Statement in Hindi
If else Statement condition को check करते है और True false के हिसाब से Code display कराते है। If else Statement के द्वारा सभी Conditional Work कर सकते है। इसके अतिरिक्त ये Decision Making होते है। जिनके द्वारा Program अलग Condition पे अलग decision ले सकता है। ये कई प्रकार के होते है।
1. If Statement
2. If else Statement
3. If else if Ladder
4. Nested If Statement
Java If Statement
If Statement का Use सिर्फ Single Condition के लिए किया जाता है। अगर Condition True है तो If Block का Code Run होगा।
Syntax of If Statement in Hindi
If (condition) {
//Code to be Executed
}
अब हम इसका एक Example देखते है।
public class Main { public static void main(String[] args) { int x=20; int y=50; if (x < y) { System.out.println("y is greater than x"); } } }
y is greater than x
1. ये Simple Java If Statement का Program है।
If else Statement in Java in Hindi
if (condition) { //Code to be Executed } else (condition) { //code to be executed }
अब इसका Example देखते है।
ifpublic class Main { public static void main(String[] args) { int x=20; int y=50; if (x > y) { System.out.println("y is greater than x"); } else { System.out.println("x is greater than y"); } } }
Output
x is greater than y
1. सबसे पहले If वाली Condition Check होगी। अगर true तो If वाला Code Run होगा
If else If Ladder Statement in Hindi
Syntax of else If Ladder Statement in Hindi
if (Condition) { //Code to be Executed } else if (condition) { //code to be executed } else if (condition) { //code to be executred } else { //code to be Executed }
अब else if else Ladder Statement के Syntax को समझनें की कोशिश करते है।
public class Main { public static void main(String[] args) { int x = 50; if (x<20) { System.out.println("x is less than 20 "); } else if (x<10) { System.out.println(" x is less than 10"); } else if (x<60) { System.out.println("x is less than 60") ; }
else {
System.out.println(“x is bigger”);
}
}
}
x is less than 60