21.9
java.util.Random
THE PACKAGE JAVA.UTIL
21.9 The Class
java.util.Random
Oh, many a shaft at random sent
Finds mark the archer little meant!
And many a word at random spoken
May soothe, or wound, a heart that's broken!
 Sir Walter Scott,
The Lady of the Lake
, Canto V, stanza 18
Each instance of class
Random
 serves as a separate, independent pseudorandom
generator of primitive values.
public class Random {
protected long seed;
protected double nextNextGaussian;
protected boolean haveNextNextGaussian = false;
public Random();
public Random(long seed);
public void setSeed(long seed);
protected int next(int bits);
public int nextInt();
public long nextLong();
public float nextFloat();
public double nextDouble();
public double nextGaussian();
}
If two
Random
 objects are created with the same seed and the same sequence
of method calls is made for each, they will generate and return identical sequences
of numbers in all Java implementations. In order to guarantee this property, partic 
ular algorithms are specified for the class
Random
. Java implementations must use
all the algorithms shown here for the class
Random
, for the sake of absolute porta 
bility of Java code. However, subclasses of class
Random
 are permitted use other
algorithms, so long as they adhere to the general contracts for all the methods.
The algorithms implemented by class
Random
 use three state variables, which
are
protected
. They also use a
protected
 utility method that on each invocation
can supply up to up to 32 pseudorandomly generated bits.
21.9.1
protected long seed;
A variable used by method
next
 ( 21.9.7) to hold the state of the pseudorandom
number generator.
646






footer




 

 

 

 

 Home | About Us | Network | Services | Support | FAQ | Control Panel | Order Online | Sitemap | Contact

java hosting

 

Our partners: PHP: Hypertext Preprocessor Best Web Hosting Java Web Hosting Inexpensive Web Hosting  Jsp Web Hosting

Cheapest Web Hosting Jsp Hosting Cheap Hosting

Visionwebhosting.net Business web hosting division of Web Design Plus. All rights reserved