-
Notifications
You must be signed in to change notification settings - Fork 35
Added JEP 356: Enhanced Pseudo-Random Number Generators demo referenc… #282
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
AloisSeckar
merged 9 commits into
AloisSeckar:master
from
sayiamarora:feature/jep356-random-generators-demo
Oct 26, 2025
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
e4611c3
Added JEP 356: Enhanced Pseudo-Random Number Generators demo referenc…
sayiamarora 5fbd9e8
updated the changes
sayiamarora 9cb01a5
Merge branch 'master' into feature/jep356-random-generators-demo
AloisSeckar a3658df
Fixed the problem
sayiamarora cffc187
Merge branch 'feature/jep356-random-generators-demo' of https://githu…
sayiamarora 0005f70
Merge branch 'master' into feature/jep356-random-generators-demo
AloisSeckar 69c4414
used the correct jumpable generator
sayiamarora d368ea7
Merge branch 'feature/jep356-random-generators-demo' of https://githu…
sayiamarora b56a274
Merge branch 'master' into feature/jep356-random-generators-demo
AloisSeckar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
src/main/java/org/javademos/java17/jep356/RandomGenerators17.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| package org.javademos.java17.jep356; | ||
|
|
||
| import org.javademos.commons.IDemo; | ||
| import java.util.random.RandomGenerator; | ||
| import java.util.random.RandomGeneratorFactory; | ||
| import java.util.random.RandomGenerator.JumpableGenerator; | ||
|
|
||
| /// Demo for JDK 17 feature JEP 356 - Enhanced Pseudo-Random Number Generators. | ||
| /// | ||
| /// Introduced new interfaces to improve random number generation: | ||
| /// - `RandomGenerator` and `RandomGeneratorFactory` | ||
| /// - Support for LXM family generators (`L32X64Mix`, `L64X128Mix`) | ||
| /// - Added streamable and jumpable generators for parallel computation. | ||
| /// | ||
| /// JEP link: | ||
| /// - [JEP 356 - Enhanced Pseudo-Random Number Generators](https://openjdk.org/jeps/356) | ||
| /// | ||
| /// Further reading: | ||
| /// - [Baeldung: Enhanced Pseudo-Random Number Generators in Java 17](https://www.baeldung.com/java-17-random-number-generators) | ||
| /// | ||
| /// @author alois.seckar@gmail.com | ||
| public class RandomGenerators17 implements IDemo { | ||
|
|
||
| @Override | ||
| public void demo() { | ||
| info(356); | ||
|
|
||
| RandomGenerator generator = RandomGenerator.getDefault(); | ||
| System.out.println("Default Random Int: " + generator.nextInt()); | ||
| System.out.println("Default Random Double: " + generator.nextDouble()); | ||
|
|
||
| JumpableGenerator jumpable = | ||
| (JumpableGenerator) RandomGeneratorFactory.of("Xoshiro256PlusPlus").create(); | ||
| System.out.println("Jumpable Random Int: " + jumpable.nextInt()); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.