Random class acting odd?

后端 未结 6 724
粉色の甜心
粉色の甜心 2020-12-03 21:33

In this code:

Random random = new Random(441287210);
for(int i=0;i<10;i++)
    System.out.print(random.nextInt(10)+\" \");
}

The output

6条回答
  •  伪装坚强ぢ
    2020-12-03 22:13

    If you use for(int i=0;i<100;i++), the sequence outputted is "more random" again. The probability of a random sequence of ten 1s in succession occuring might be small, but it's not impossible. (Insofar that given enough samples, any sequence is almost certain to occur.)

    It's merely an interesting coincidence.

提交回复
热议问题