Files
openide/java/java-impl/resources/inspectionDescriptions/UseBulkOperation.html
2025-02-05 04:43:28 +00:00

29 lines
916 B
HTML

<html>
<body>
Reports single operations inside loops that could be replaced with a bulk method.
<p>
Not only are bulk methods shorter, but in some cases they may be more performant as well.
</p>
<p><b>Example:</b></p>
<pre><code> void test(Collection&lt;Integer&gt; numbers) {
List&lt;Integer&gt; result = new ArrayList&lt;>();
for (Integer i : numbers) {
result.add(i);
}
}
</code></pre>
<p>After the fix is applied:</p>
<pre><code>
void test(Collection&lt;Integer&gt; numbers) {
List&lt;Integer&gt; result = new ArrayList&lt;>();
result.addAll(numbers);
}
</code></pre>
<!-- tooltip end -->
<p>
The <b>Use Arrays.asList() to wrap arrays</b> 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 <code>Arrays.asList()</code> call.
</p>
<p><small>New in 2017.1</small></p>
</body>
</html>