2 ms·
Huh? I didn't say anything about nextInt. The point is that if every time you want a random number you construct a new Random object using the default construc
by gjm11 17y ago
Huh? I didn't say anything about nextInt.
The point is that if every time you want a random number you construct a new Random object using the default constructor, then (1) if you're using version 1.4 or earlier then rapidly repeated "random" number generation will give you the same result over and over, and (2) if you're using version 1.5 or later then it's (quite rightly) almost entirely unspecified what you'll get and whether it will be "random enough" for any particular purpose and whether it will be terribly inefficient.
(I'm wondering whether perhaps you missed the fact that lucifer's proposed constructions involve making a new Random object each time you want some randomness.)