Back to Intellij Community

ExplicitArrayFilling

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

2025.3-rc-2461 B
Original Source

Reports loops that can be replaced with Arrays.setAll() or Arrays.fill() calls.

This inspection suggests replacing loops with Arrays.setAll() if the language level of the project or module is 8 or higher. Replacing loops with Arrays.fill() is possible with any language level.

Example:

for (int i=0; i<array.length; i++) {
     array[i] = calc(i);
  }

After the quick-fix is applied:

Arrays.setAll(array, this::calc);

New in 2017.1