Back to Intellij Community

LocalCanBeFinal

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

2025.3-rc-2415 B
Original Source

Reports local variables or parameters that may have the final modifier added to their declaration.

Example:

ArrayList<Integer> list = new ArrayList();
  fill(list);
  return list;

After the quick-fix is applied:

final ArrayList<Integer> list = new ArrayList();
  fill(list);
  return list;

Use the inspection's options to define what kinds of parameters or local variables should be reported.