Java - for loop Condition expression

Introduction

The for loop condition-expression must evaluate to a Boolean value of true or false.

The condition-expression is optional.

If it is omitted, a Boolean value of true is used, which results in an infinite loop.

You can use a break statement to stop the loop.

The following two for-loop statements are the same and result in infinite loops:

for( ; ; ); // Implicitly condition-expression is true

for( ; true; ); // Explicit true is used here

Related Topic