In this code:
Random random = new Random(441287210);
for(int i=0;i<10;i++)
System.out.print(random.nextInt(10)+" ");
}
The output is 1 1 1 1 1 1 1 1 1 1
, every time.
Why is this? Isn't Random
supposed to be... well... random? I thought that the Random
class use System.nanoTime
, so the output should be generally random. Can someone please explain?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…