Does the random value randomize the random values, make the generator more random?

I have this code which simulates 10 coins:

public void FlipCoinTenTimes() {
    Random randomNumberGenerator = new Random();

    // Generate 10 random numbers
    for (int i = 0; i < 10; i++) {
        System.out.println(randomNumberGenerator.nextInt(2) == 0 ? "Heads" : "Tails");


Does setting seeds randomly take a long time to make this method more random? Ie more 50/50 than if I deleted the line setSeed()



source to share

1 answer

No , setting a seed like this won't make it "more random". the default constructor will use a random seed.

The Random class uses a linear congruential generator to generate a pseudo-random series of bits. The state of a random class is contained in something called a seed. When a class is requested for a random number, the seed is updated .

This should not affect the distribution by manually resetting the distribution of random numbers. If you want a better distribution that is also difficult to predict, you can use SecureRandom




All Articles