Back to Intellij Community

MultipleVariablesInDeclaration

java/java-impl/resources/inspectionDescriptions/MultipleVariablesInDeclaration.html

2025.3-rc-2768 B
Original Source

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;

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