Inspectopedia 2025.2 Help

Multiple variables in one declaration

Reports multiple variables that are declared in a single declaration and suggest creating a separate declaration for each variable.

Some coding standards prohibit such declarations.

Example:

int x = 1, y = 2;

After the quick-fix is applied:

int x = 1; int y = 2;

Locating this inspection

By ID

Can be used to locate inspection in e.g. Qodana configuration files, where you can quickly enable or disable it, or adjust its settings.

MultipleVariablesInDeclaration
Via Settings dialog

Path to the inspection settings via IntelliJ Platform IDE Settings dialog, when you need to adjust inspection settings directly from your IDE.

Settings or Preferences | Editor | Inspections | Java | Code style issues

Configure the inspection:

  • Use the Ignore 'for' loop declarations option to ignore multiple variables declared in the initialization of a 'for' loop statement, for example:

    for (int i = 0, max = list.size(); i > max; i++) {}
  • Use the Only warn on different array dimensions in a single declaration option to only warn when variables with different array dimensions are declared in a single declaration, for example:

    String s = "", array[];

New in 2019.2

Inspection options

Here you can find the description of settings available for the Multiple variables in one declaration inspection, and the reference of their default values.

Ignore 'for' loop declarations

Default value:

Selected
Only warn on different array dimensions in a single declaration

Default value:

Not selected

Suppressing Inspection

You can suppress this inspection by placing the following comment marker before the code fragment where you no longer want messages from this inspection to appear:

//noinspection MultipleVariablesInDeclaration

More detailed instructions as well as other ways and options that you have can be found in the product documentation:

Inspection Details

By default bundled with:

IntelliJ IDEA 2025.2, Qodana for JVM 2025.2,

Last modified: 18 September 2025