RandomGeneratorFactory Picks Seeded Algorithms

List built-in generator algorithms, select one by name, and prove same-seed reproducibility so tests and replays stay deterministic.

JavaData Integrity

Code

snippet
import java.util.random.RandomGeneratorFactory;

public class DicePicker {

    public static void main(String[] args) {
        // list the JVM's built-in random number generator algorithms (deprecated ones skipped)
        RandomGeneratorFactory.all()
                .filter(factory -> !factory.isDeprecated())
                .forEach(factory ->
                        System.out.println(factory.name() + " stateBits=" + factory.stateBits()));

        // select an algorithm by name: an unknown name throws IllegalArgumentException
        RandomGeneratorFactory<?> factory = RandomGeneratorFactory.of("L64X128MixRandom");

        // the same seed reproduces the same sequence: the basis for regression tests and incident replay
        var genA = factory.create(20261114L);
        var genB = factory.create(20261114L);
        for (int i = 0; i < 3; i++) {
            System.out.println("draw: " + genA.nextInt(100) + " / " + genB.nextInt(100));
        }
    }
}

How the snippet works

RandomGeneratorFactory Picks Seeded Algorithms reduces to the class DicePicker and the function main.

The loop for (int i = 0; i < 3; i++) is the only repeated construct.

Applying it

The demo output is labeled (draw:), so every printed line maps back to its originating operation.

Statements that matter

.filter(factory -> !factory.isDeprecated())
.forEach(factory ->
        System.out.println(factory.name() + " stateBits=" + factory.stateBits()));

Interactive Tools for This Topic

FAQ

What does RandomGeneratorFactory Picks Seeded Algorithms print when run?
Running the file directly is enough — expect labeled output lines such as `draw:`.