Switch Statement In Java
Switch Statement ?
It is mainly used in multi-option programs. Switch case statement is used when we have
multiple conditions and we need to perform different action based on the condition. When we have multiple conditions and we need to execute a block of statements when a particular condition is satisfied.
➦It is mainly used in
➦The switch statement evaluates an expression, then attempts to match the result of the expression to one of several possible cases.
➦Each case contains a value and a list of statements.
➦The flow of control transfer to statement associated with the first case value that matches.
➦the case value can be of any
break statement is used as the last statement in each case's statement list.
break statement causes control to transfer to the
end of the switch statement.
break statement is not used, the
flow of control will continue
executing the next case also.
➦A switch statement can have an optional
x has a value of 0!
you have selected : 12