Professional Documents
Culture Documents
JAVA Statements
JAVA Statements
JAVA Statements
if else Statement
if else Statement
if else Statement
switch()
case:
…
default:
Switch-case Statement
A switch statement is used to compare the value of a variable with multiple values. For each of
these values, you can define a set of statements to execute. The switch statement evaluates its
expression, then executes all statements that follow the matching case label. Each break
statement terminates the enclosing switch statement. The break statements are necessary
because without them, statements in switch blocks fall through: All statements after the
matching case label are executed in sequence, regardless of the expression of subsequent case
labels, until a break statement is encountered.