Java Programming

5.5 For loop

Java for loop used to repeat execution of statement(s) until a certain condition holds true.
The general form of the for statement can be expressed as follows:

for (initialization; termination; increment)
{
statement(s)…
}

You can initialize multiple variables, test many conditions and perform increments or decrements on many variables according to requirement.
All three components of for loop are optional.

For example, to execute a statement 5 times:
for (i = 0; i < 5; i++) statements…; Another way of doing this is: i = 4; while (i>=0)
statements…;

Download for more knowledge

https://play.google.com/store/apps/details?id=ab.java.programming

Leave a comment