Let me also talk about the differences between Java: Random. nextint () and math. Random ().
I don't care about efficiency. Today, when I quickly sorted data structures, I used random numbers to see this point. In fact, here we should say exactly
The difference between random. nextint (int n) and math. Random () * n is because the difference exists. Look at the documentation. Why are there so many other people?
The first is to comment on their efficiency, and they are fundamentally different. Because Random. nextint (int n) is from 0 to N, but n is not included, the problem arises here,
Math. Random () * n is probably very close to N. Most of them use integers. Why do we need to compare them like this?
So this should be called
What is the difference between random. nextint (N) and math. Random () * (n-1) or random. nextint (n + 1) and math. Random () * n,
Another important difference is that, in practical use, when used together with other applications, there will be great differences. I don't need to talk about it here.
Haha