• We Code
  • We Design
  • We Develope
  • We Write
  • We Share

menu

Sunday, August 26, 2012

Branching in JAVA or Control statements in JAVA


Control statements are used to make branching (if,if-else,if-else-if etc) ,looping(for,while,do-while),skiping(switch) and exiting block of code(countinue,break)



  1. if counditions
  2. if()
  3. if(),else
  4. if(),else if(),else



if()  tells whether the condition is satisfied or not ,if condition satisfies the following block of if() code (also called as if() condition body )  will execute.



if(coundition)

 {
   do something
  }

if(),else


this statement helps to select one possible block of code out of two conditions.


if(coundition)

 {
   do something
  }
else
{
  do something else
}

if(),else if(),else

                 This statement helps to select one possible block of code out of three conditions.


if(condition)

 {
   do something
  }
else  if(another condition)
 {
   do something else
  }
else
{
  do something else
}

Nasted if conditions


In this we will write conditon under an another condition .


if(condition 1)

{
    if(coundition 2)
      {
         
        if(condition 3)
          {
            do something
           }
          
        else (condition 4)   
           {
             do something
            }
     
     else (condition 5)
      {          
         do something
       }

else(condition 6)

  {
    do something
 }
      

0 comments:

Post a Comment

...