KnowledgeBoat Logo

Computer Applications

What are the unique features of for loop?

Java Iterative Stmts

ICSE

30 Likes

Answer

for loop is an entry-controlled loop. Its general syntax is as follows:

for (initialization; conditional; increment/decrement)  
{  
    //Java Statements  
    ..  
    ..  
}
  1. The initialization expression initializes the loop control variable and is executed only once when the loop starts. It is optional and can be omitted by just putting a semicolon.
  2. The conditional expression is tested at the start of each iteration of the loop. Loop will iterate as long as this condition remains true.
  3. The increment/decrement expression updates the loop control variable after each iteration.
  4. The body of the loop that consists of the statements that needs to be repeatedly executed.

Answered By

13 Likes


Related Questions