• A repetition control statement is used to repeatedly execute a block of code
until a certain condition is met.
• Three repetition control statements are while, do–while, and for.
• The count-controlled loop executes the loop body for a fixed number of
times.
• The sentinel-controlled loop executes the loop body until any one of the
designated values called a sentinel is encountered.
• Count-controlled loops can be implemented most naturally with the for
statements.
• Sentinel-controlled loops can be implemented most naturally with the while
or do–while statements.
• The while statement is called a pretest loop, and the do–while statement is
called a posttest loop. The for statement is also a pretest loop.
• Reading a value before the loop statement is called a priming read.
• Off-by-1 error and infinite loop are two common mistakes in writing a loop
control.
• The loop-and-a-half repetition control is the most general way of writing a
loop. The break statement is used within the loop body to exit the loop when
a certain condition is met.
• The showConfirmationDialog method of the JOptionPane class is used to
display a confirmation dialog.
• The nested for statement is used very often because it is ideally suited to
process tabular data.
• The random method of the Math class is used to generate a pseudorandom
number.