इंटरमीडिएट Java
Jim White
Java Developer
यदि condition true है ✅ ➡ कुछ करें
यदि condition false है ❌ ➡ कुछ न करें
यदि score 90+ है ➡ "Great job!" प्रिंट करें
यदि score 90 से कम है ➡ कुछ न प्रिंट करें
if (condition) {
// Code to run
}
यदि condition true है, तो कर्ली ब्रैकेट्स के अंदर का कोड चलता है
==, !=, >, <, >=, <= जैसे comparison operators का उपयोग करें// Print "Great job!" if score is >= 90
if (score >= 90) {
System.out.println("Great job!");
}
int score = 94;
if (score >= 90) {
System.out.println("Excellent!");
}
if (score >= 70) {
System.out.println("Good job!");
}
if (score < 70) {
System.out.println("Try again!");
}
Excellent!
Good job!
हम अलग-अलग conditions रख सकते हैं, बशर्ते वे true/false पर evaluate हों
if (score != 0){
System.out.println("Well, you got some points!");
}
if (message.equals("F")){
System.out.println("Try again!");
}
if (testResult == 100) {
System.out.println("Wow, you got it all!");
}
इंटरमीडिएट Java