php    php100   android
当前位置:首页 » Java.util包 »

Java.util.Random类

评论  编辑

The java.util.Random class instance is used to generate a stream of pseudorandom numbers.Following are the important points about Random:

  • The class uses a 48-bit seed, which is modified using a linear congruential formula.

  • The algorithms implemented by class Random use a protected utility method that on each invocation can supply up to 32 pseudorandomly generated bits.

类声明

以下是声明java.util.Random class:

public class Random
   extends Object
      implements Serializable

类构造方法

S.N.构造方法 & 详细描述
1Random()
This creates a new random number generator.
2Random(long seed)
This creates a new random number generator using a single long seed.

类方法

S.N.方法 & 描述
1protected int next(int bits)
This method generates the next pseudorandom number.
2 boolean nextBoolean()
This method returns the next pseudorandom, uniformly distributed boolean value from this random number generator's sequence.
3 void nextBytes(byte[] bytes)
This method generates random bytes and places them into a user-supplied byte array.
4 double nextDouble()
This method returns the next pseudorandom, uniformly distributed double value between 0.0 and 1.0 from this random number generator's sequence.
5 float nextFloat()
This method returns the next pseudorandom, uniformly distributed float value between 0.0 and 1.0 from this random number generator's sequence.
6 double nextGaussian()
This method 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.
7 int nextInt()
This method returns the next pseudorandom, uniformly distributed int value from this random number generator's sequence.
8 int nextInt(int n)
This method returns a pseudorandom, uniformly distributed int value between 0 (inclusive) and the specified value (exclusive), drawn from this random number generator's sequence.
9 long nextLong()
This method returns the next pseudorandom, uniformly distributed long value from this random number generator's sequence.
10 void setSeed(long seed)
This method sets the seed of this random number generator using a single long seed.

方法继承

此类从以下类继承了上面列出的方法

  • java.util.Object


贡献/合作者

正在开放中...
 

评论(条)

  • 还没有评论!