diff --git a/src/java.base/share/classes/java/util/random/RandomGeneratorFactory.java b/src/java.base/share/classes/java/util/random/RandomGeneratorFactory.java
index 552d7b03d536f..a2ff3407a1591 100644
--- a/src/java.base/share/classes/java/util/random/RandomGeneratorFactory.java
+++ b/src/java.base/share/classes/java/util/random/RandomGeneratorFactory.java
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -67,7 +67,7 @@
  * {@link RandomGeneratorFactory#create()} is used for random seed
  * construction. Example;
  *
- * <pre>{@code
+ * {@snippet :
  *    RandomGeneratorFactory<RandomGenerator> factory = RandomGeneratorFactory.of("Random");
  *
  *     for (int i = 0; i < 10; i++) {
@@ -76,7 +76,7 @@
  *             System.out.println(random.nextDouble());
  *         }).start();
  *     }
- * }</pre>
+ * }
  *
  * RandomGeneratorFactory also provides methods describing the attributes (or properties)
  * of a generator and can be used to select random number generator
@@ -87,16 +87,17 @@
  * {@link RandomGenerator RandomGenerators}
  * with the highest number of state bits.
  *
- * <pre>{@code
+ * {@snippet :
  *     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()
  *         .orElse(RandomGeneratorFactory.of("Random"));
  *     System.out.println(best.name() + " in " + best.group() + " was selected");
  *
  *     RandomGenerator rng = best.create();
  *     System.out.println(rng.nextLong());
- * }</pre>
+ * }
  *
  * @since 17
  *