Execution of the switch Statement

  1. The selector expression is evaluated; the result will be some integral value.
  2. The labels are searched in the order they appear in the code. The first occurrence of the selector's value is the case that is selected.
  3. Statements following this case label are executed in the order they appear.
  4. Statements are executed until a break statement is reached.
  5. When a break statement is reached, control is transferred to the first statement that follows the entire switch statement .

Previous page
Next page

Back to Lesson 8 Index
Back to Outline