The selection statements we covered in Chapter 5 alter the control flow of a program.
In this chapter we will cover another group of control statements called repetition
statements. Repetition statements control a block of code to be executed for a fixed
number of times or until a certain condition is met. We will describe Java’s three
repetition statements: while, do–while, and for. In addition to the repetition statements,
we will introduce the third useful method of the JOptionPane class, called
showConfirmDialog. The confirmation dialog is often used in conjunction with a
repetition statement. For example, we can set up a repetition statement to keep playing
a game while the user replies yes to a confirmation dialog. Finally, in optional
Section 6.11, we will describe recursive methods. A recursive method is a method
that calls itself. Instead of a repetition statement, a recursive method can be used to
program the repetition control flow.
To learn more about the book this website supports, please visit its Information Center.