Java.util.RandomThe principle of Next method
Better reference Documentation:
http://isky001.iteye.com/blog/1339979
PackageRandom.utilrandom;ImportJava.util.Random; Public classTestrandom { Public Static voidMain (string[] args) {Random ran1=NewRandom (10); System.out.println ("Generates a sequence of random integers in [0,10] using a random object with seed 10:"); for(inti = 0; I < 10; i++) {System.out.print (Ran1.nextint (10) + ""); } System.out.println (); Random ran2=NewRandom (10); System.out.println ("Generates a sequence of random integers in [0,10] using another random object with a seed of 10:"); for(inti = 0; I < 10; i++) {System.out.print (Ran2.nextint (10) + ""); } Random ran3=NewRandom (10); System.out.println ("Generates a sequence of random integers in [0,10] using another random object with a seed of 10:"); for(inti = 0; I < 10; i++) {System.out.println (Ran3.nextint ()); } System.out.println (); Random Ran4=NewRandom (10); System.out.println ("Generates a sequence of random integers in [0,10] using another random object with a seed of 10:"); for(inti = 0; I < 10; i++) {System.out.println (Ran4.nextint ()); } }}
Math.random () is essentially called RandomNumberGeneratorHolder.randomNumberGenerator.nextDouble (); That is java.util.Random.nextDouble ()
There is also an article that explains the linear congruence formula.
Http://www.cnblogs.com/xkfz007/archive/2012/03/27/2420154.html
One more english document explanation Nextseed = (Oldseed * multiplier + addend) & mask;
Http://en.wikipedia.org/wiki/Linear_congruential_generator
Java.util.Random in-depth understanding