June 2024
Beginner to intermediate
957 pages
16h 58m
English
In Chapter 25, as you certainly noticed, the while statement was used to iterate for both a known number and an unknown number of times (in situations where the number of iterations was not known at the time the loop started iterating). In other words, the while statement was used to create both definite and indefinite loops.
Since definite loops are so frequently used in computer programming, almost every computer language, including Java, incorporates a special statement that is notably more readable and convenient than the while statement—and this is the for statement.
The general form of the for statement, is
Read now
Unlock full access