Chapter Summary
A loop is a programming construct that repeats an action some number of times. The part that is repeated is called the body of the loop. Every repetition of the loop body is called a loop iteration.
Java has three kinds of loop statements: the
whilestatement, thedo-whilestatement, and theforstatement.Both the
whilestatement and thedo-whilestatement repeat the body of the loop while a boolean expression is true. Thedo-whilestatement executes its body at least once, but thewhilestatement might not execute its body at all.The logic of a
forstatement is identical to that of awhileloop. Its initialization, test, and update steps are given together, rather than dispersed throughout the loop. Theforstatement often ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access