Читать книгу OCP Oracle Certified Professional Java SE 17 Developer Study Guide - Jeanne Boyarsky - Страница 184

The switch Statement

Оглавление

A switch statement, as shown in Figure 3.3, is a complex decision-making structure in which a single value is evaluated and flow is redirected to the first matching branch, known as a case statement. If no such case statement is found that matches the value, an optional default statement will be called. If no such default option is available, the entire switch statement will be skipped. Notice in Figure 3.3 that case values can be combined into a single case statement using commas.


FIGURE 3.3 The structure of a switch statement

Because switch statements can be longer than most decision-making statements, the exam may present invalid switch syntax to see whether you are paying attention.

OCP Oracle Certified Professional Java SE 17 Developer Study Guide

Подняться наверх