...
In general, you should declare each variable on its own line with an explanatory comment about the role of the variableregarding its role. Although not required for conformance with this guide, this practice is also recommended in the Code Conventions for the Java Programming Language Conventions 2009 Section 6.1, "Number Per Line".
When more than one variable is declared in a single declaration, ensure that both the type and the initial value of the each variable are self evident.
...
Code Block | ||
---|---|---|
| ||
int i = 1, j = 1; |
It is preferrable to declare Prefer declaring each variable on a separate line; however, but multiple variables on one line can be are acceptable if when they are small temporary variables, such as array indexes.
...
Compliant Solution (different types)
This compliant solution not only places each declaration on its own line, as well as using it also uses the preferred notation for array declaration.
...