Add java17-features module: runnable demos and captured output for the ankurm.com java17-features article

This commit is contained in:
2026-10-20 17:13:58 +00:00
parent 8b9447a393
commit 5a076c826f
23 changed files with 261 additions and 0 deletions
+12
View File
@@ -0,0 +1,12 @@
import java.util.random.RandomGenerator;
import java.util.random.RandomGeneratorFactory;
/** JEP 356: RandomGenerator interface and named algorithms. Seeded, so the output is stable. */
public class RandomDemo {
public static void main(String[] args) {
RandomGenerator g = RandomGeneratorFactory.of("L64X128MixRandom").create(42L);
System.out.println("L64X128MixRandom nextInt(100) x3: " + g.nextInt(100) + " " + g.nextInt(100) + " " + g.nextInt(100));
System.out.println("ThreadLocalRandom implements RandomGenerator: " + (java.util.concurrent.ThreadLocalRandom.current() instanceof RandomGenerator));
System.out.println("algorithms >= 10: " + (RandomGeneratorFactory.all().count() >= 10));
}
}