Control Statement's in Java


Control Statements means the control of program is change according to that condtions.
Java supports following control statements these are:

if statement:


    syntax is

                   if(condition)//code;
                         else//code;

 Nested ifs Statement:

              syntax is

                  if(condition){//code;
                      if(condition)//code;
                         if(condition)//code;
                         else//code;}
                          else//code;


The if-else-if Statement:

        
                   syntax is
                    
                   if(condition)
                          //code;
                         else if(condition)
                            //code;
                             else if(condition)
                            //code;
                                  . 
                                  . 
                                  .
                                 else
                                //code;

                    

 Switch Statement:

                          syntax is
                          
                               switch (expression)
                               { case1: // code  
                                     break; 
                                  case2: // code 
                                          break; 
                                        default :
                                          //code}

          Iteration Statement:

  While.

                   syntax is

                              while(condition)
                                 { // body of loop or code}

      Do-while.

                                syntax is
                          
                                do { // body of loop }
                                  while (condition);

      For loop Statement.

                        syntax is 

                 for(initialization; condition; iteration) 
                 { // loop body } 


      For-each loop statement.

                       syntax is 

                   for(type itr-var : collection) 
                {code-block;}


      Nested For loops Statements.

           syntax is 
          
             
             for(type itr-var : collection) 
                {for(type itr-var : collection) 
                {code-block;}
                  code-block;}}  
         

      Comments

      Popular posts from this blog

      Inheritance in Java

      Operators in Java Language?

      Type Casting or Conversion in Java