Java If Else statement with Example जाने हिंदी में…. || Java tutorial

Hello दोस्तों! आज मैं आपको इस पोस्ट में Java If Else statement with Example  हिंदी में….   बताऊंगा,

तो चलिए शुरू करते हैं:-


Java If Else statement


  If statement and java Conditions

Java गणित से सामान्य logical condition  का support करता है |

  • Less then : a <  b
  • Less then or Equal to a <= b
  • Greater then a > b
  • Greater then or Equal to a >=  b
  • Equal to a == b
  • Not Equal a != b

आप इन condition का उपयोग विभिन्न decision के लिए अलग-अलग कार्य करने के लिए कर सकते हैं |

Java में निम्नलिखित conditional statement हैं :-

If  :      यदि specified condition सत्य है, तो code का एक block execute करने के लिए If statement का  उपयोग करें.

Else :      यदि same condition झूठी है, तो code का एक block execute करने के लिए Else statement का  उपयोग करें.

Else_If :    यदि First condition झूठी है, तो If Else statement का उपयोग करें.

Switch :   कोड के many alternative block को execute करने के लिए Switch statement का उपयोग करें.


The If Statement :

यदि specified condition सत्य है, तो If statement execute होता है |

Syntax:

if (condition) {
// block of code to be executed if the condition is true 
}

नीचे दिए गए उदाहरण में हम यह जानने के लिए दो value का test करते हैं कि क्या 20 18 से अधिक है। यदि condition true  है, तो कुछ text print करें :

Example:

public class Myclass {

public static void main (String [] args) {

if 20>18

{

System.out.println("20 is greater then 18");

}

}

}

हम variables का परीक्षण भी कर सकते हैं |

Example:

public class Myclass {

public static void main (String [] args) {

int x=20;
int y=18;

if x>y

{

System.out.println("x is greater then y");

}

}

}

Java Type Casting जाने हिंदी में|| Java tutorial 

Java Operators ( जावा में ओपरेटर क्या होते हैं तथा कितने प्रकार के होते हैं।) 


The Else Statement :

यदि specified condition false है, तो Else statement execute होता है |

Syntax:

if (condition) {
// block of code to be executed if the condition is true 
}
else (condition) {
// block of code to be executed if the condition is false
}
Example:

public class Myclass {

public static void main (String [] args) {

int time = 20;
if (time < 18);
{
System.out.println("Good day");
}

else{
System.out.println("Good evening");
}
}
}

//output "Good evening"

The Else_If Statement :

Else_If statement में अगर If की condition true होती है तो If का statement execute होता है,

अगर if का condition false  होता है तो वो अगले condition पर जाकर check करता है, अगर वो condition true होता है तो वो उसका statement execute करता है,

अगर कोई भी condition true नहीं होती  तो वो else statement execute करता है,

Syntax:

if (condition 1) {
// block of code to be executed if the condition is true 
}
else if (condition 2) {
// block of code to be executed if the condition is true 
}
else  {
// block of code to be executed if the condition is false
}
Example:

public class Myclass {

public static void main (String [] args) {

int time = 25;
if  (time < 18);
{
System.out.println("Good day");
}

else if (time < 20);

{
System.out.println("Good afternoon");
}

else{
System.out.println("Good evening");
}
}
}

//output "Good evening"

Note:- ये पोस्ट आपको कैसी लगी आप कमेंट कर के बताईये !अगर आपको कुछ पूछना या अपनी राय देनी  हो तो आप हमे कमेंट या [email protected] ईमेल करके बता सकते है हम पूरी कोसिस करेंगे की आपका रिप्लाई जल्दी से जल्दी दे सखे ….


इसे भी देखे:

Hello दोस्तों! नीचे दिए गए links पर click  करके आपको हम  इस पोस्ट में  (Computer Online Test) की Practice कराएंगे जिससे आप अपने  CCC, O level , कम्प्युटर GK की practice कर सकते है.

इस post के द्वारा आप  अपनी कम्प्युटर की  नॉलेज बड़ सकते है.

उसके साथ ही साथ आप अपने कई प्रकार के पेपरो की भी तैयरी  भी कर सकते है.

जैसे की CCC, O level , कम्प्युटर GK की practice कर सकते है,

Leave a Comment