mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-16 14:23:28 +07:00
27 lines
623 B
HTML
27 lines
623 B
HTML
<html>
|
|
<body>
|
|
Reports suspicious calls to <code>Collection.toArray()</code>.
|
|
<p>The following types of calls are considered suspicious:</p>
|
|
<ul>
|
|
<li>
|
|
when the type of the array
|
|
argument is not the same as the array type to which the result is casted.
|
|
</li>
|
|
<li>
|
|
when the type of the array argument does not match the type parameter in the collection declaration.
|
|
</li>
|
|
</ul>
|
|
<p><b>Example:</b></p>
|
|
<pre><code>
|
|
void m1(List list) {
|
|
Number[] ns = (Number[]) list.toArray(new String[0]);
|
|
}
|
|
|
|
void m2(List<Number> list) {
|
|
Number[] ns = list.toArray(new String[0]);
|
|
}
|
|
</code></pre>
|
|
|
|
|
|
</body>
|
|
</html> |