Beginning with JDK 5 there two forms of the loop. the first is the traditional form that has been in use the original version of java. The second is the new for-each form both types of for loops are discussed here.
for(initialization;condition;iteration){
}
the for loop operates as follows when the loop first starts the initialization portion of the loop is executed. Generally is an expression that set the value of the for loop control variable, which acts as a counter that controls the loop. It is important to understand that the initialization expression is only executed. Next condition is evaluated. This must be a Boolean expression. It usually tests the loop control variable against a target value.
if this expression is true then the body of the loop is executed. if it is false the terminates next the iteration portion of the loop is executed this is usually an expression that increments or decrement the loop control variable.
Social Links:
FaceBook / howtolearnjava
LinkedIn: / suresh-bushaboina-604068189
/ ojlatechnology