Inspectopedia Help

Loop can be replaced with 'List.replaceAll()'

Reports loops which can be collapsed into a single List.replaceAll() call.

Example:

for (int i = 0; i < strings.size(); i++) { String str = strings.get(i).toLowerCase(); strings.set(i, str); }

After the quick-fix is applied:

strings.replaceAll(String::toLowerCase);

This inspection only reports if the language level of the project or module is 8 or higher.

New in 2022.1

Inspection options

Option

Type

Default

Don't warn if the parameter of 'List.replaceAll()' is multiline lambda

Checkbox

true

Inspection Details

Available in:

IntelliJ IDEA 2023.3, Qodana for JVM 2023.3

Plugin:

Java, 233.SNAPSHOT

Last modified: 13 July 2023