Friday, December 26, 2014

Control Statements in Java

We have 3 types of Control Statements in Java. They are,
-- Conditional Control Statements
-- Iterative Control Statements
-- Transfer/Jump Control Statements
Control Statements in java
1) Conditional control statements:
Conditional Statements will work based on the conditions. We have different types of Conditional Statements. They are,
i) if : If the condition is true then the control will execute the block of statements otherwise the control will not enter into if block
Syntax:
if(condition)
{
statement1;
statement2;
----------
}
ii) if-else : If the condition is true then the control will execute the if block otherwise the control will execute else block
Syntax:
if(condition)
{
statement1;
statement2;
}
else{
statement3;
statement4;
}
2) Iterative Control Statements:
Iterative control statements are used to execute the group of statements repeatatively based on a condition.
ex:
i) while
ii) do-while
iii) for
3) Transfer/Jump Control Statements:
whenever these statements are encountered then the control will be transfered from one place to another.
ex:
i) break
ii) continue
iii) return

No comments:

Post a Comment