Re: [問題] 亂數
※ 引述《necole236 (necole236)》之銘言:
: http://java.sun.com/j2se/1.4.2/docs/api/java/util/Random.html#Random()
: Random
: public Random()
: Creates a new random number generator. Its seed is initialized to a value
: based on the current time:
: public Random() { this(System.currentTimeMillis()); }
: Two Random objects created within the same millisecond will have the same
: sequence of random numbers.
: 我看到的定義是這樣子寫的
: 他並沒有說除了當前時間之外,還做了什麼「會設一個和其他 invocation
: 很可能會不同的值作 seed」
: 假設你是對的,那他是如何設定一個不同的值做 seed ?
我那段是在 JDK5 的 API 找出來的.
看來 Sun 在 JDK5 改變了 Random no-op constructor .
JDK5 裡的 Random():
public Random() { this(++seedUniquifier + System.nanoTime()); }
alien
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 202.155.236.82
推
07/29 17:58, , 1F
07/29 17:58, 1F
推
07/29 18:00, , 2F
07/29 18:00, 2F
→
07/29 18:07, , 3F
07/29 18:07, 3F
推
07/29 18:08, , 4F
07/29 18:08, 4F
→
07/29 18:10, , 5F
07/29 18:10, 5F
→
07/29 18:11, , 6F
07/29 18:11, 6F
→
07/29 18:13, , 7F
07/29 18:13, 7F
推
07/29 18:25, , 8F
07/29 18:25, 8F
→
07/29 19:42, , 9F
07/29 19:42, 9F
→
07/29 19:44, , 10F
07/29 19:44, 10F
推
07/29 22:07, , 11F
07/29 22:07, 11F
→
07/30 12:06, , 12F
07/30 12:06, 12F
討論串 (同標題文章)