Inspectopedia Help

Bulk operation can be used instead of iteration

Reports single operations inside loops that could be replaced with a bulk method.

Not only are bulk methods shorter, but in some cases they may be more performant as well.

Example:

void test(Collection<Integer> numbers) { List<Integer> result = new ArrayList<>(); for (Integer i : numbers) { result.add(i); } }

After the fix is applied:

void test(Collection<Integer> numbers) { List<Integer> result = new ArrayList<>(); result.addAll(numbers); }

The Use Arrays.asList() to wrap arrays option allows to report arrays, even if the bulk method requires a collection. In this case the quick-fix will automatically wrap the array in Arrays.asList() call.

New in 2017.1

Inspection options

Option

Type

Default

Use 'Arrays.asList()' to wrap arrays

Checkbox

true

Inspection Details

Available in:

IntelliJ IDEA 2023.3, Qodana for JVM 2023.3

Plugin:

Java, 233.SNAPSHOT

Last modified: 13 July 2023