here is the syntax for java for loopfor (initializationconditionincrementloop_statement where each of the sections initializationconditionand increment can be empty in the initialization sectionwe can declare an index variable that will only exist in the scope of the for loop for exampleif we want loop that indexes on counterand we have no need for the counter variable outside of the for loopthen declaring something like the following for (int counter conditionincrementloop_statement will declare variable counter whose scope is the loop body only in the condition sectionwe specify the repeat (whilecondition of the loop this must be boolean expression the body of the for loop will be executed each time the condition is true when evaluated at the beginning of potential iteration as soon as condition evaluates to falsethen the loop body is not executedandinsteadthe program executes the next statement after the for loop in the increment sectionwe declare the incrementing statement for the loop the incrementing statement can be any legal statementallowing for significant flexibility in coding thusthe syntax of for loop is equivalent to the followinginitializationwhile (conditionloop_statementincrementexcept thatin javaa while loop cannot have an empty boolean conditionwhereas for loop can the following example shows simple for loop in java