Tuesday, 8 October 2013

Control statement in Java

Advertisement

Control statement in any programming language is used to control the flow of the statement in the application.
That is why it is termed as " control ".
There are three types of control statement i.e
1> Conditional control statement.
2> Looping/iteration control statement.
3> Unconditional control statement.

Conditional Control Statement 

It is termed as conditional that means it must deal with conditions and accordingly, the statement defined within these control structures will be executed.
In Java there are two types of conditional control statement i.e
1> if statement
2> switch statement

The only point you all have to remember about these two control statements is that both will execute only once conditionally. And if the condition is false then it will not execute even for one time, and simply skip all those codes written within these control blocks.

Note:- For details about if and switch follow their respective topics later in this tutorial. 

Looping control statement

It is termed as looping that means it meant for executing same code multiple time. If any user wants their code to execute more than once then go for these types of control statement and even user can be able to execute their code " infinite " times.
In java there are three types of looping control statements i.e
1> for statement
2> while statement
3> do-while statement

Note:- For details on for just  Click Here .
For details on while Click Here .

Unconditional control statement

It is a type of control statement which is used to either stop or continue the flow of execution . It is generally used with conditional and looping control statement but has some restriction defining / using it with these control statement, will discuss the same in their respective topic later in this tutorial.
There are two types of unconditional control statement in java i.e
1> break statement
2> continue statement

Note:- For details about break Click Here .
and for details on continue  Click Here .



EmoticonEmoticon