g., 89.5) as a double (a floating-point
number which can include a fractional part). The Double class is one of Java??™s ???wrapper classes,??? which we
discussed in the section on data types.
In summary, this for loop will begin executing with the value of i set to 1. After each execution of the
loop, the value of i will be incremented. The loop will continue to execute as long as the value of i is no greater
than the number of students. When i becomes greater than the number of students, the conditional test in the
second expression of the for statement will fail (will be false), and the program will ???drop out??? of the loop and
continue at the next statement following the for loop body.
Here is the syntax of the for statement:
for(
; ; )
The conditional expression must evaluate to either true or false. If the conditional expression is true, the
body of the for loop will be executed, but not otherwise. The is usually a compound statement, which
is a code block enclosed in curly braces. Each statement within the body must be terminated with a semicolon.
while
Another structure to control looping (iteration) is the while statement. Suppose we don??™t know how many
student scores are in the file of student scores.
Pages:
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204