Back to Intellij Community

ParameterCanBeLocal

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

2025.3-rc-2536 B
Original Source

Reports method parameters that are redundant and can be replaced with a local variable.

If all usages of a parameter are preceded by an assignment to that parameter, the parameter can be replaced with a local variable. Such a parameter is unnecessary, as values that are passed to it are overwritten. Usually, the problem appears as a result of refactoring.

Example:

void test(int p) {
    p = 1;
    System.out.print(p);
  }

After the quick-fix is applied:

void test() {
    int p = 1;
    System.out.print(p);
  }