The structure switch-case chooses which part of the programming code to execute based on the calculated value of a certain expression.
switch (expression)
{
case 1:
statements;
break;
case 2:
statements;
break;
default:
statements;
break;
}
|
The switch statement is a clear way to implement selection among many options (namely, a choice among a few alternative ways for executing the code). It requires a selector, which is calculated to a certain value. The selector type could be an integer, char, string or enum. If we want to use for example an array or a float as a selector, it will not work. For noninteger data types, we should use a series of if statements.
We Are Currently Working On Our Android Application Development and We already have two YouTube channels their name is CodeX or NightHawk. CodeX is for programming related videos and NightHawk is for online game streaming so please supporting us and Subscribe to our channels, Thank you