简体   繁体   中英

Why does the JDK have both Math.random() and the Random class?

Is it just because of "large API syndrome" or generating random numbers that are more biased favored in some situations? If it was..I would think that controlling the bias-ness would be important.

They're the same, really. Just a convenience method. Check the javadoc here . Additionally, you're able to re-seed by creating random objects, while Math.random() will use a static Random instance.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM