...
- local variable declaration statements ([Java 2005, §14.4)]
- field declarations ([Java 2005, §8.3)]
- field (constant) declarations ([Java 2005, §9.3)]
Noncompliant Code Example (Initialization)
...
Code Block | ||
---|---|---|
| ||
public class Example { private T a; // purpose of a... private T b; // purpose of b... private T[] c; // purpose of c[]... private T d; // purpose of d... public Example(T in){ a = in; b = in; c = (T[]) new Object[10]; d = in; } } |
Exceptions
DCL01-EX1EX0: 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 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="f447ed245a688216-deb7e14d-4d8440ec-810e92d7-51a98e97602fdccddb7dbef3"><ac:plain-text-body><![CDATA[ | [[Conventions 2009 | AA. Bibliography#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="92f3381487d8e73b-75d55d31-47ad4f63-8a21badc-9916f30525bc8d05e430e459"><ac:plain-text-body><![CDATA[ | [[ESA 2005 | AA. Bibliography#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="e1d8a372c0f7060f-3b7a6d6a-49e944ae-875e8b43-b66fcfe2a5561781e7987737"><ac:plain-text-body><![CDATA[ | [[JLS 2005 | AA. Bibliography#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> |
| |||||
| |||||
| |||||
|
...