Constructor Summaryrandom () Creates A New Random Number Generator.random (Long Seed) Creates A New Random Number Generator Using A Single Long Seed:
Method Summaryprotected intnext (int bits) Generates the next pseudorandom number. BooleannextBoolean () Returns the next pseudorandom, uniformly distributed boolean value from this random number generator's sequence. VoidnextBytes (byte [] bytes) Generates random bytes and places them into a user-supplied byte array. doublenextDouble () Returns the next pseudorandom, uniformly distributed double value between 0.0 and 1.0 from this random number generator's sequence. floatnextFloat () Returns the next pseudorandom, uniformly distributed float value between 0.0 and 1.0 from this random number generator's sequence. doublenextGaussian () Returns the next pseudorandom, Gaussian ( "normally") distributed double value with mean 0.0 and standard deviation 1.0 from this random number generator's sequence. intnextInt () Returns the next pseudorandom, uniformly distributed int value from this random number generator's sequence. intnex tInt (int n) Returns a pseudorandom, uniformly distributed int value between 0 (inclusive) and the specified value (exclusive), drawn from this random number generator's sequence. longnextLong () Returns the next pseudorandom, uniformly distributed long value from this random number Generator's sequence. voidsetseed (long seed) sets the seed of this random number generator using a single long seed.
Use example:
Import java.util.random;
Public class randomnum {
Public static void main (String [] args) {
Random ran = new random (); system.out.println (ran.nextint ()); // Generate any random integer
System.out.println (ran.nextBoolean ()); //
System.out.println (ran.nextdouble ()); //
System.out.println (ran.nextfloat ()); //
System.out.println (RAN.NEXTLONG ()); //
System.out.println (ran.nextint (100)); // Generate random integers of 0 to 100
}
}
result:
-1116918815
False
0.3570466757532643
0.69238234
7423008150361503085
88
Since the result is the result of each run of the regular