8274683: Code example provided by RandomGeneratorFactory does not compile
Reviewed-by: darcy
This commit is contained in:
parent
42baaa3bb8
commit
4732b1d038
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -67,7 +67,7 @@ import jdk.internal.util.random.RandomSupport.RandomGeneratorProperties;
|
|||||||
* {@link RandomGeneratorFactory#create()} is used for random seed
|
* {@link RandomGeneratorFactory#create()} is used for random seed
|
||||||
* construction. Example;
|
* construction. Example;
|
||||||
*
|
*
|
||||||
* <pre>{@code
|
* {@snippet :
|
||||||
* RandomGeneratorFactory<RandomGenerator> factory = RandomGeneratorFactory.of("Random");
|
* RandomGeneratorFactory<RandomGenerator> factory = RandomGeneratorFactory.of("Random");
|
||||||
*
|
*
|
||||||
* for (int i = 0; i < 10; i++) {
|
* for (int i = 0; i < 10; i++) {
|
||||||
@ -76,7 +76,7 @@ import jdk.internal.util.random.RandomSupport.RandomGeneratorProperties;
|
|||||||
* System.out.println(random.nextDouble());
|
* System.out.println(random.nextDouble());
|
||||||
* }).start();
|
* }).start();
|
||||||
* }
|
* }
|
||||||
* }</pre>
|
* }
|
||||||
*
|
*
|
||||||
* RandomGeneratorFactory also provides methods describing the attributes (or properties)
|
* RandomGeneratorFactory also provides methods describing the attributes (or properties)
|
||||||
* of a generator and can be used to select random number generator
|
* of a generator and can be used to select random number generator
|
||||||
@ -87,16 +87,17 @@ import jdk.internal.util.random.RandomSupport.RandomGeneratorProperties;
|
|||||||
* {@link RandomGenerator RandomGenerators}
|
* {@link RandomGenerator RandomGenerators}
|
||||||
* with the highest number of state bits.
|
* with the highest number of state bits.
|
||||||
*
|
*
|
||||||
* <pre>{@code
|
* {@snippet :
|
||||||
* RandomGeneratorFactory<RandomGenerator> best = RandomGeneratorFactory.all()
|
* RandomGeneratorFactory<RandomGenerator> best = RandomGeneratorFactory.all()
|
||||||
* .sorted(Comparator.comparingInt(RandomGenerator::stateBits).reversed())
|
* .filter(rgf -> !rgf.name().equals("SecureRandom")) // SecureRandom has MAX_VALUE stateBits.
|
||||||
|
* .sorted(Comparator.comparingInt(RandomGeneratorFactory<RandomGenerator>::stateBits).reversed())
|
||||||
* .findFirst()
|
* .findFirst()
|
||||||
* .orElse(RandomGeneratorFactory.of("Random"));
|
* .orElse(RandomGeneratorFactory.of("Random"));
|
||||||
* System.out.println(best.name() + " in " + best.group() + " was selected");
|
* System.out.println(best.name() + " in " + best.group() + " was selected");
|
||||||
*
|
*
|
||||||
* RandomGenerator rng = best.create();
|
* RandomGenerator rng = best.create();
|
||||||
* System.out.println(rng.nextLong());
|
* System.out.println(rng.nextLong());
|
||||||
* }</pre>
|
* }
|
||||||
*
|
*
|
||||||
* @since 17
|
* @since 17
|
||||||
*
|
*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user