April 2017
Beginner
504 pages
14h 11m
English
The for loop inside the while loop will go through all the elements from the first (indexed with zero in Java) up till the last (indexed with n-1). Generally, the for loop has the same syntax as in C:
for( initial expression ; condition ; increment expression ) block
First, the initial expression is evaluated. It may contain variable declaration, as in our example. The variable j in the preceding example is visible only inside the block of the loop. After this, the condition is evaluated, and after each execution of the block, the increment expression is executed. The loop repeats so long as the condition is true. If the condition is false right after the execution of the initial expression, the loop does not execute at all. The ...
Read now
Unlock full access