There are many ways to generate random numbers using Java 2 SDK underlying libraries. But if you can't keep up with these class libraries, you may be using a low-efficient random number generation mechanism, worse: you may get the random number of uniform distribution. This article will show you a relatively reliable random number generation method while comparing other methods. Since the initial version of JDK released, we can use the java.util.random class to generate random numbers. In JDK1.2, the Random class has a method called nextint (): public int nextint (int N) gives a parameter n, and Nextint (n) will return a random number greater than equal to 0 less than n, namely: 0 <= NEXTINT (N) If you perform the above two code, the result of the first code will be greater than 715,000,000, taking into account the midpoint of the numerical range (MIDPOINT) is 715, 827, 882, which is an acceptable result. However, you will be surprised to find the average of the second code to get more than 600,000,000. Why is the result of the second code? Correct the nature, the problem is unevenness of numerical distribution. When you perform a modeling operation, you will turn excessive numbers into smaller. This makes smaller numbers easier to produce. Using nextint (Range) will solve the above three problems. There is also a random number generation method - use math.random (). What is the effect of this method? SUM = 0; for (int i = 0; i