Aselection control statement is used to alter the sequential flow of control.
The if and switch statements are two types of selection control.
Aboolean expression contains conditional and boolean operators and evaluates to true or false.
Three boolean operators in Java are AND (&&), OR (||), and NOT (!).
DeMorgan’s laws state that !(P &&Q) and !P || !Q are equivalent and that !(P || Q) and !P && !Q are equivalent.
Logical operators && and || are evaluated by using the short-circuit evaluation technique.
Aboolean flag is useful in keeping track of program settings.
Anif statement can be a part of the then or else block of another if statement to formulate nested-if statements.
Careful attention to details is important to avoid illogically constructed nested-if statements.
When the equality symbol == is used in comparing the variables of reference data type, we are comparing the addresses.
The switch statement is useful when expressing a selection control based on equality testing between data of type char, byte, short, or int.
The break statement causes the control to break out of the surrounding switch statement (note: also from other control statements introduced in Chapter 6).
The standard classes introduced in this chapter are