for Loops
In your programming, you find many circumstances in which a loop is useful. You can use them to keep doing something several times, such as an antivirus program that opens each new email received to look for viruses. You also can use loops to cause the computer to do nothing for a brief period, such as an animated clock that displays the current time once per minute.
A loop statement causes a computer program to return to the same place more than once, like a stunt plane completing an acrobatic loop.
Java’s most complex loop statement is for. A for loop repeats a section of a program a fixed number of times. The following is an example:
for (int dex = 0; dex < 1000; dex++) { if (dex % 12 == 0) { System.out.println("#: " + ...
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