mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-16 14:23:28 +07:00
26 lines
631 B
HTML
26 lines
631 B
HTML
<html>
|
|
<body>
|
|
Reports calls to
|
|
<code>java.util.Random.nextDouble()</code> that are used to create a positive integer number by multiplying
|
|
the call by a factor and casting to an integer.
|
|
<p>
|
|
For generating a random positive integer in a range,
|
|
<code>java.util.Random.nextInt(int)</code> is simpler and more efficient.
|
|
</p>
|
|
<p><b>Example:</b></p>
|
|
<pre><code>
|
|
int getRandomInt() {
|
|
return (int) ((new Random()).nextDouble() * SIZE);
|
|
}
|
|
</code>
|
|
</pre>
|
|
<p>After the quick-fix is applied:</p>
|
|
<pre><code>
|
|
int getRandomInt() {
|
|
return (new Random()).nextInt(SIZE);
|
|
}
|
|
</code></pre>
|
|
<!-- tooltip end -->
|
|
|
|
</body>
|
|
</html> |