Random class java.util

11. java.util classes Random

  • Examples of such a flow for generating a pseudo-random number.
  • If Random creates two instances of the same seed the same sequence of method calls for each instance, which will generate and return the same sequence of numbers.

Construction method

  • public Random (): Creates a new random number generator.
  • public Random (long seed): creates a new random number generator using a single long seed.

Common method nextLong()

  • public int nextInt (): Returns the next pseudo-random number sequence int value of the random number generator uniformly distributed.
  • public int nextInt (int n): Returns a pseudo-random number, which is derived from the random number generator sequence, between 0 (inclusive) and the specified value (not included) uniformly distributed int value.
  • public double nextGaussian (): Returns the next pseudo-random number that is the random number generator from the sequence of a Gaussian ( "normal") Double value distribution, mean 0.0, standard deviation 1.0.
    • nextBytes(byte[] bytes) ,nextDouble() ,nextFloat() ,nextLong()

Guess you like

Origin www.cnblogs.com/Stephanie-boke/p/11515224.html