Chapter Summary
A branching statement chooses and then performs one of a number of actions. The
if-elsestatement andswitchstatement are branching statements.A boolean expression combines variables and comparison operators such as < to produce a value that is either true or false.
An
if-elsestatement tests the value of a boolean expression and takes one of two actions according to whether the value is true or false.You can omit the
elsepart to get anifstatement that takes an action if a boolean expression is true but takes no action if the expression is false.A compound statement is a sequence of Java statements, all enclosed in a pair of braces.
You can nest
if-elsestatements. Either or both of theifpart and theelsepart can have ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access