- Use single-branch selection in Java (if statement)
- Use two-branch selection in Java (if/else statement)
- Use multi-branch selection in Java (nested if/else statements)
- if (booleanExpression) statement; // single branched
- if (booleanExpression) statement; // two branched
else statement;
- blocks of code delimited with curly braces and containing
multiple statements can be used in place of the single statements above
- examples will be shown in class
- if statements can be nested
- if (eligibleForOvertime) {
if (hoursWorked > 40) {
grossPay = hoursWorked * rate + (hoursWorked-40) * rate/2;
} else {
grossPay = hoursWorked * rate;
}
}