Features of for Loop
https://www.computersprofessor.com/2016/06/features-of-for-loop.html
More than one variable
can be initialized at a time in the for statement.
Ex
: for (p
= 1, n = 0 ; n < 17 ; + + n).
|
The increment section may
also have more than one part.
Ex
: for (n = 1, m = 50; n < = m ; n = n + 1, m = m – 1)
{
……………
……………
}
|
The multiple arguments in
the increment section are separated by commas.
|
The test condition may
have any compound relation is the testing need hot be limited only to the
loop control variable.
Ex
: Sum = 0;
for (i = 1, i < 0 && sum < 100, i + +)
{
…………….
…………….
}
|
Another unique aspect of
for loop is that one (or) more sections can be omitted.
……………
……………
for (; m! = 100 ;)
{
System.out.println (m) ;
m = m + 5;
}
…………..
…………..
|