switch Statements
The next type of control flow is the switch statement. The switch statement is the first control flow statement that does not require a Boolean evaluation. A switch statement consists of a control expression and a block of statements delineated by case labels. The control expression is evaluated and the resulting value determines which case will be executed. Each case is labeled with a unique constant expression that is used in making this determination. Control is passed to the case whose expression matches the value of the control expression. If there is no match, control passes to the default label. If there is no default label, control passes to the first statement after the switch block.
An example of a switch statement ...
Get Special Edition Using Java 2 Standard Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.