java.util
Class Random
java.lang.Object
|
+--java.util.Random
- public class Random
- extends Object
A class to generate random numbers.
To avoid getting the same sequence every time the random number generator
should be seeded based on some external stimulae, such as the time between
button presses.
Constructor Summary |
Random()
Create a new random number generator. |
Random(int seed)
Create a new random number generator using the given seed value. |
Method Summary |
int |
next()
Returns the next integer in the psuedo random sequence. |
MAX_RAND
public static final int MAX_RAND
seed
protected int seed
Random
public Random()
- Create a new random number generator. The seed is initialized to a
constant value.
Random
public Random(int seed)
- Create a new random number generator using the given seed value.
- Parameters:
seed
- seed value for the psuedo random sequence.
next
public int next()
- Returns the next integer in the psuedo random sequence. The numbers
generated are in the range 0 .. MAX_RAND
- Returns:
- the next integer value in the sequence.