/**
* Creates a new random number generator using a single {@code long} seed.
* The seed is the initial value of the internal state of the pseudorandom
* number generator which is maintained by method {@link #next}.
*
* <p>The invocation {@code new Random(seed)} is equivalent to:
* <pre> {@code
* Random rnd = new Random();
* rnd.setSeed(seed);}</pre>
*
* @param seed the initial seed
* @see #setSeed(long)
*/
public Random(long seed)
你把47去掉就每次不一样了。
jdk 1.60版本中是这样写的:
深入了解可以去搜索:伪随机数
随机数种子都是一样的,他能不一样么,所谓的随机数是没有办法真正随机的,都是通过一系列算法算出来的,同一个随机数种子算出的随机数是同一个,所以一般都是用当前的时间作为随机数种子,也就是默认没有传随机数种子的时候。而
new Random(47)中的47就是随机数种子,所以要想结果每次都不一样,那么随机数种子就不能每次一样。