|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectRandNumGenerator
public class RandNumGenerator
Kalamazoo College Utility Classes:
The RandNumGenerator
class provides a representation
for random number generators.
Example of how to use RandNumGenerator
:
RandNumGenerator randNumGen = new RandNumGenerator();
int randomInt = randNumGen.nextInt(4);
double randomDouble = randNumGen.nextDouble();
Constructor Summary | |
---|---|
RandNumGenerator()
Constructs a random number generator. |
Method Summary | |
---|---|
boolean |
nextBoolean()
Returns a pseudorandom, uniformly distributed boolean
value from this random number generator's sequence. |
double |
nextDouble()
Returns a pseudorandom, uniformly distributed double
value between 0.0 and 1.0 from this
random number generator's sequence. |
int |
nextInt(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. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public RandNumGenerator()
Method Detail |
---|
public boolean nextBoolean()
boolean
value from this random number generator's sequence. The values
true
and false
are produced with
(approximately) equal probability. For more technical details,
see the documentation for the Math.random()
method.
boolean
value from this random number generator's sequencepublic double nextDouble()
double
value between 0.0
and 1.0
from this
random number generator's sequence.
double
value between 0.0
and 1.0
from
this random number generator's sequence.public int nextInt(int n)
int
value
between 0
(inclusive) and the specified value (exclusive),
drawn from this random number generator's sequence. For more
technical details, see the class documentation for the
Random
class.
n
- the bound on the random number to be returned.
Must be positive.
int
value between 0 (inclusive) and n
(exclusive).
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |