January 2003
Beginner to intermediate
1200 pages
23h 42m
English
The next step after working with conditional statements is to handle loops. Like JavaScript, Java supports a for loop, a while loop, and a do...while loop.
Here's how you use a Java for loop in general, Note that the statement that makes up the body of the for loop can be a compound statement; it can be made up of several single statements enclosed in curly braces:
for (initialization_expression; end_conditon; iteration_expression) { statement }
You place an expression in the initialization part of the for loop (which often initializes a variable—that is, a loop index—to 0), and then you place a test condition in the test part of the loop that is tested each time the code in the loop executes. If the test is ...