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

22 lines
675 B
HTML

<html>
<body>
Reports unnecessarily complex collection operations which have simpler alternatives.
<p>Example:</p>
<pre><code>
void f(String[] array, Collection&lt;String&gt; collection) {
String[] strings = Arrays.asList(array).subList(0, 10).toArray(new String[0]);
boolean contains = collection.containsAll(Collections.singletonList("x"));
}
</code></pre>
<p>After the quick-fix is applied:</p>
<pre><code>
void f(String[] array, Collection&lt;String&gt; collection) {
String[] strings = Arrays.copyOf(array, 10);
boolean contains = collection.contains("x");
}
</code></pre>
<!-- tooltip end -->
<p><small>New in 2018.1</small></p>
</body>
</html>