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

Is it just because of the "big API syndrome" or the generation of random numbers that are more prone to preferences in some situations? If that were the case ... I would have thought it was important to control bias.

+6
source share
1 answer

In fact, everything is the same. Just a convenient method. Check out javadoc here . Alternatively, you can Math.random() creating random objects, and Math.random() will use a static random instance.

+9
source

Source: https://habr.com/ru/post/904125/


All Articles