Chapter Summary

  • A branching statement chooses and then performs one of a number of actions. The if-else statement and switch statement 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-else statement 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 else part to get an if statement 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-else statements. Either or both of the if part and the else part can have ...

Get Java: An Introduction to Problem Solving and Programming, 8th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.