Cette page n'est pas encore disponible en français, sa traduction est en cours. Si vous avez des questions ou des retours sur notre projet de traduction actuel, n'hésitez pas à nous contacter.
Metadata
ID:java-best-practices/forloop-variable-count
Language: Java
Severity: Warning
Category: Best Practices
Description
The presence of multiple control variables in a for loop can obscure the range of values over which the loop iterates and make your code brittle and difficult to debug.
To follow this rule, regular for loops should have only one control variable.
Arguments
max-variables: Maximum number of control variables. Default: 1.
Non-Compliant Code Examples
publicclassMain{publicvoidfoo(){for(inti=0,j=0;i<10;i++,j+=2){// more than one control variablefoo();}}}