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.


Field Summary
static int MAX_RAND
           
protected  int seed
           
 
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.
 
Methods inherited from class java.lang.Object
equals
 

Field Detail

MAX_RAND

public static final int MAX_RAND

seed

protected int seed
Constructor Detail

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.
Method Detail

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.