Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Declaring each variable on a separate line is the prefered preferred method. However, multiple variables on one line are acceptable when they are trivial temporary variables such as array indexes.

...

When an Object method, such as toString(), is overridden, a programmer could accidentally provide an implementation for type T that fails to consider that c is an array of T, rather than a reference to an object of type T.

...

However, the programmer's actual intent could have been to invoke toString() on each individual element of the array c.

...

DCL01-EX1: Note that the declaration of a loop counter in a for statement is in violation of this guideline because the declaration is not on its own line with an explanatory comment about the variable's role. However, declaration of loop indices in for statements is not only a common idiom ; it but also provides the benefit of restricting the scope of the loop index to the for loop itself. This is a specific reason to relax this guideline.

...

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="bf1302204db18f74-2d911d8d-42ef4465-a2d6a86f-d3e48fc134bd8e7a5bc7f930"><ac:plain-text-body><![CDATA[

[[Conventions 2009

AA. References#Conventions 09]]

Section 6.1, "Number Per Line"

]]></ac:plain-text-body></ac:structured-macro>

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="977d9b8b14f7fa1e-fcfeb1d7-499c4db3-907fb89e-27d17858743cdf526464ca69"><ac:plain-text-body><![CDATA[

[[ESA 2005

AA. References#ESA 05]]

Rule 9: Put single variable definitions in separate lines.

]]></ac:plain-text-body></ac:structured-macro>

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="e7e6c26368732eb3-cfe17f61-454543db-9f1ea079-59865dfba8079964c727b6d4"><ac:plain-text-body><![CDATA[

[[JLS 2005

AA. References#JLS 05]]

[§8.3, "Field Declarations"

http://java.sun.com/docs/books/jls/third_edition/html/classes.html#8.3]

]]></ac:plain-text-body></ac:structured-macro>

 

§9.3, "Field (Constant) Declarations"

 

§14.4, "Local Variable Declaration Statements"

 

§6.1, "Declarations"

 

§4.3.2, "The class Object"

...