Loops
Loops
Unlike for and while loops, which test the loop condition at the
top of the loop, the do...while loop checks its condition at the
bottom of the loop.
A do...while loop is similar to a while loop, except that a
do...while loop is guaranteed to execute at least one time.
int a = 10;
do {
System.out.println << "value of a: " << a << endl;
a = a + 1;
}
while( a < 20 );
Execute a sequence of statements multiple times
and abbreviates the code that manages the
loop variable.
General syntax
for ( init; condition; increment )
{
statement(s);
}
FOR LOOP
for( int a = 10; a < 20; a = a + 1 )
{
system.out. << "value of a: " << a << endl;
}
FOR LOOP…
NESTED LOOPS