...
Declarations of loop indices should be included within a for
statement even though this technically violates this guideline because the declaration is not on its own line with an explanatory comment)if that results in multiple variable declarations in that statement:
Code Block | ||
---|---|---|
| ||
public class Example { void function() { int mx = 100; // some max value for (int i = 0; i < mx; ++i ) { /* ... */ } } } |
Such declarations are not required to be in a separate line and the explanatory comment may also be omitted.
Bibliography
Section 6.1, "Number Per Line" | |
[ESA 2005] | Rule 9: Put single variable definitions in separate lines. |
[JLS 2011] | |
| |
| |
| |
|
...