Note: You will see the string hello print to the console infinitely, one line after another. So, considering these two statements, we can provide the boolean value true, in place of condition, and the result is a infinite for loop. Secondly, we also know that the condition evaluates to a boolean value.
Example 1 – Java Infinite For Loop with True for Conditionįirstly, we know that the condition in for loop statement has to always evaluate to true for it to become infinite Loop. As the condition is never going to be false, the control never comes out of the loop, and forms an Infinite Loop as shown in the above diagram, with blue paths of execution.