Class | Tree | Index | Help
| AP® Computer Science Marine Biology Simulation
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## Class RandNumGenerator

    java.lang.Object
      |
      +--RandNumGenerator

public class RandNumGenerator
extends java.lang.Object

AP® Computer Science Marine Biology Simulation:
The `RandNumGenerator` class provides a singleton `java.util.Random` object for random number generation. Using this class, many different objects can share a single source of random numbers. This eliminates the potential problem of having multiple random number generators generating sequences of numbers that are too similar.

Example of how to use `RandNumGenerator`:

           import java.util.Random;

           Random randNumGen = RandNumGenerator.getInstance();
           int randomNum = randNumGen.nextInt(4);
           double randomDouble = randNumGen.nextDouble();

The `RandNumGenerator` class is copyright© 2002 College Entrance Examination Board (www.collegeboard.com).

Version:
  1 July 2002
See Also:
  `Random`

Constructor Summary
`RandNumGenerator()`

Method Summary
`static java.util.Random` | `getInstance()` Returns a random number generator.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### RandNumGenerator

    public RandNumGenerator()

Method Detail

### getInstance

    public static java.util.Random getInstance()

  Returns a random number generator. Always returns the same `Random` object to provide a better sequence of random numbers.

Class | Tree | Index | Help
| AP® Computer Science Marine Biology Simulation
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright© 2002 College Entrance Examination Board