< previous page page_461 next page >

Page 461
Statement4 and continue with Statement5. The break statement causes an immediate exit from the Switch statement. We'll see shortly what happens if we omit the break statements.
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif 3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
Switch Expression The expression whose value determines which switch label is selected. It cannot be a floating point expression.
The syntax template for the Switch statement is
0461-01.gif
IntegralExpression is an expression of integral typechar, short, int, long, or enum (we discuss enum in the next chapter). The optional SwitchLabel in front of a statement is either a case label or a default label:
0461-02.gif
In a case label, ConstantExpression is an integral expression whose operands must be literal or named constants. The following are examples of constant integral expressions (CLASS_SIZE is a named constant of type int):
3
CLASS_SIZE
A
2 * CLASS_SIZE + 1

 
< previous page page_461 next page >