5.5. The while and do-while loops

[5.1] Create and use while loops

[5.3] Create and use do-while loops

You’ll learn about while and do-while loops in this section. Both of these loops execute a set of statements as long as their condition evaluates to true. Both of these loops work in the same manner except for one difference: the while loops checks its condition before evaluating its loop body, and the do-while loop checks its condition after executing the statements defined in its loop body.

Does this difference in behavior make a difference in their execution? Yes, it does, and in this section, you’ll see how.

5.5.1. The while loop

A while loop is used to repeatedly execute a set of statements as long ...

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.