Java Control Statement in hindi (Java control statement क्या है?)

 

Java Control Statement in hindi

Control statements वो statements होते हैं। जिनसे आप program का execution (flow) control करते है। कोनसे statements कब execute होंगे ये control statements के द्वारा ही तय किया जाता है। 

Java -  If Statement : Java If statement in hindi 

if Statement में अगर Condition true होती है तब Statement Execute होता है |

Syntax for If Statement :

1
2
3
if(condition){
	statement(s);
}

Example for If  Statement :

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
class Myif
{
    public static void main(String args[])
    {
       int x = 3;
        if (x > 10){
            System.out.println("Inner If");
        }
		System.out.println("Outer If");
    }
} 

Output :

1
Outer If


Java - If Else Statement : Java If Else statement in hindi 

if else Statement में अगर Condition true हो तो वो if का statement Execute करता है | अगर Condition false होती है तो else का Condition करता है |

Syntax for If Else Statement :

1
2
3
4
5
if(condition){
	statement(s);
}else{
	statement(s);
}

Example for If Else  Statement :

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
class MyifElse
{
    public static void main(String args[])
    {
       int x = 3;
        if (x > 10){
            System.out.println("Inner If");
        }else{
			System.out.println("Inner Else");
		}
		System.out.println("Outer If Else");
    }
} 

Output :

1
2
Inner Else
Outer If Else


Else If Statement : Java Else If statement in hindi 

else if Statement में अगर if की Condition true होती है तो if का statement execute होता है | अगर if का condition false होता है तो वो अगले condition पर जाकर check करता है | अगर वो condition true होता है तो वो उसका statement execute करता है | अगर कोई भी condition true नहीं होती तो वो else का statement execute करता है |

Syntax for Else If Statement :

1
2
3
4
5
6
7
if(condition){
	statement(s);
}else if(condition){
	statement(s);
}else{
	statement(s);
}

Example for Else If Statement :

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
class MyElseIf
{
    public static void main(String args[])
    {
       int x = 3;
        if (x > 10){
            System.out.println("x is greater than 10");
        }else if (x < 10){
			System.out.println("x is less than 10");
		}else{
			System.out.println("x is equal to 10");
		}
		System.out.println("Outer Else If");
    }
}

Output :
1
2
x is less than 10
Outer Else If

Java - Switch Case Statement : Java switch case statement in hindi 

Switch case statement में expression होता है और उससे related कुछ cases होते है | जो case उस expression या declare किये हुए variable से match होती है तब वो output में print होता है | अगर कोई भी case expression से match नहीं होती तो वो default का statement output में print करेगा | आपको हर statement के बाद break लगाना पड़ता है, इसका मतलब वो उसके पहले का statement ही print करेगा | अगर आप break नहीं लगाते तो वो पहला और दूसरा ये दोनों statement को print करेगा | default case के बाद break नहीं लगाते |

Syntax for Switch Case Statement :

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
switch (expression){

	case value1 :
	statement1 ;
	break;

	case value2 :
	statement2 ;
	break;

	case valueN :
	statementN ;
	break;
	
	default :
	statement3 ;
	}

Example for Switch Case Statement :

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
class MySwitch{
 public static void main(String args[]){
   int x = 1;
   switch(x){
     case 0:
     System.out.println("x is equal to 0.");
     break;
 
     case 1:
     System.out.println("x is equal to 1.");
     break;
 
     case 2:
     System.out.println("x is equal to 2.");
     break;

     default:
     System.out.println("x is not found.");
     break;
 }
}
}

Output :

1
x is equal to 1.

Java - Break Statement : Java break statement in hindi 

Break Statement Program के loops और switch case के execution का काम किसी condition पर बंद कर देता है |

Syntax for Break Statement :

1
break;

Example for Break Statement :

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
class MyBreak{
 public static void main(String args[]){
	int i=0;
    while ( i < 20 ){

    System.out.println("value of i is %d\n", i);
    
	i++;
		if ( i == 10 ){
		break;
		}
	}
 }
}

Output :

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
value of i is 0
value of i is 1
value of i is 2
value of i is 3
value of i is 4
value of i is 5
value of i is 6
value of i is 7
value of i is 8
value of i is 9


Java - Continue Statement : Java continue statement in hindi 

Continue Statement Program के loops के condition के हिसाब से बीचवाले statements को skip कर देता है और बादवाले statement को execute करता है |


Syntax for Continue Statement :


1
continue;


Example for Continue Statement :


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
class MyContinue{
 public static void main(String args[]){
   int i;

   for(i=0; i<10; i++){
		if(i==7){
	 
			System.out.println("Number "+ i +" is skipped.");
    
		continue;
		}
		System.out.println(i);
	}
 }
}


Output :


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
0
1
2
3
4
5
6
Number 7 is skipped.
8
9



अगर आपको यह पोस्ट 📑 पसंद आई हो तो अपने मित्रों के साथ जरूर शेयर करें। धन्यवाद !
Maxon

Hello there! I'm Maxon, a dedicated UI/UX designer on a mission to transform digital experiences into intuitive, user-centric journeys. With a keen eye for detail and a passion for crafting aesthetically pleasing interfaces, I strive to create designs that not only look stunning but also enhance usability and functionality.

Post a Comment

Previous Post Next Post