If a while
or for
statement uses a loop counter, and increments or decrements the counter by more than one, it must use an inequality operator (that is, <
, <=
, >
, or >=
) to terminate the loop. This prevents the loop from executing indefinitely or until the counter wraps around and reaches the final value. (See NUM00-J. Detect or prevent integer overflow.)
Noncompliant Code Example
...
[JLS 2005] | 15.20.1 Numerical Comparison Operators <, <=, >, and >= |
...
MSC55MSC53-JJG. Finish every set of statements associated with a case label with a break statement 49. Miscellaneous (MSC)