5.9. Review notes

if and if-else constructs:

  • The if statement enables you to execute a set of statements in your code based on the result of a condition, which should evaluate to a boolean or a Boolean value.
  • The multiple flavors of an if statement are if, if-else, and if-else-if-else.
  • The if construct doesn’t use the keyword then to define code to execute when an if condition evaluates to true. The then part of the if construct follows the if condition.
  • An if construct may or may not define its else part.
  • The else part of an if construct can’t exist without the definition of its then part.
  • It’s easy to get confused with the common if-else syntax used in other programming languages. The if-elsif and if-elseif statements aren’t used in Java ...

Get OCA Java SE 8 Programmer I Certification Guide now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.