Math.random() versus Random.nextInt(int)

后端 未结 4 1426
灰色年华
灰色年华 2020-11-22 07:21

What is the difference between Math.random() * n and Random.nextInt(n) where n is an integer?

4条回答
  •  日久生厌
    2020-11-22 08:19

    another important point is that Random.nextInt(n) is repeatable since you can create two Random object with the same seed. This is not possible with Math.random().

提交回复
热议问题