Flow control it will manage how the program flow has to go.
selection statements - if-else, switch
Iterative - while, do while, for, for-each.
Transfer statements - break, continue, return, try-catch-finally and assert.
If-else :
if(conditional expressions){
code to be executed;
} else{
code to be executed;
}
Nested If:
if(condition){
code to be executed;
}else if(condtion){
code to be executed;
}else{
code to be executed;
}
Switch Statements
switch(x)
{
case1:
Action1;
break;
case2:
Action2;
break;
default:
Default Action;
}
While
while(condition){
Body of the loop;
}
it will execute till the condition is false.
Do while
it will execute first and then check for the condition.
do{
execute the condition;
}while(condition);
For loop
is a looping statement if we know the number of iterations.
for(initialization;condition; increment or decrement){
loop body;
}
Top comments (0)