Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

 Using a null seed value may prevent such problems. Java's default seed uses system's time in milliseconds. However, you should neither use two different generators with a null seed value nor "resetting" generator's instance more than once (using new Random() multiple times) as you may get identical numbers in the former case and number not actually random in the latter one.

Code Block
bgColor#FFCCCC
import java.util.Random;
// ...

Random number = new Random();
//...
for (int i=0; i<20; i++)
{
   // re-seed generator
   number = new Random();
   // generate another random integer in the range [0,20]
   int n = number.nextInt(21);
   System.out.println(n);
}

...

Recommendation

Severity

Likelihood

Remediation Cost

Priority

Level

MSC30-J

medium

unlikely

medium

P4

L3 

Automated Detection

TODO

Related Vulnerabilities

...