Using the Comma
There will be times when you will want to include more than one statement in the
initialization and iteration portions of the for loop. For example, consider the loop in the following program:
As you can see, the loop is controlled by the interaction of two variables. Since the loop is go vented by two variables, it would be useful if both could be included in the for statement, itself, instead of b being handled manually. Fortunately, Java provides a way to accomplish this. To allow two or more variables to control a for loop, Java permits you to include multiple statements in both the initialization and iteration portions of the for. Each statement is separated from the next by a comma.
In this example, till initialization portion sets the values of both a and b. The two
comma-separated statements in the iteration portion are executed each time the loop repeats. The program generates the following output:
if O are familiar with C/C+ then yo,II ill those languages tile Conan is all operator that can be used ill expression. loiterer, this is not wit II Jam. III Java, the Cincinnati is a separator this applies to tile for loop.