Class MultipleVariableDeclarationsCheck

  • All Implemented Interfaces:
    Configurable, Contextualizable

    public class MultipleVariableDeclarationsCheck
    extends AbstractCheck

    Checks that each variable declaration is in its own statement and on its own line.

    Rationale: the Java code conventions chapter 6.1 recommends that declarations should be one per line/statement.

    To configure the check:

     <module name="MultipleVariableDeclarations"/>


     public class Test {
       public void myTest() {
         int mid;
         int high;
         // ...
         int lower, higher; // violation
         // ...
         int value,
             index; // violation
         // ...
         int place = mid, number = high;  // violation

    Parent is

    Violation Message Keys:

    • multiple.variable.declarations
    • multiple.variable.declarations.comma