Switch statement: -
The switch statement is also called the conditional statement like else – if statement. But by this statement we can take multi values with our condition.
Its syntax is:
Switch (condition)
{
Case value 1:
Statement 1;
Break;
Case value 2:
Statement 2;
Break;
Case value 3 :
Statement 3;
Break;
Default:
Statement 4;
}
In this structure first of all value of condition is checked, if it methods with case value 1 then statement is executed. If it method with case value 2, then statement 2 is executed. If the method with case value 3, then statement 3 is executed otherwise in false situation, default statement is executed.
Posted by: Wasim Javed
No comments:
Post a Comment