Random numbers are a crucial part of several computer programs, and pseudo-random number generators (PRNGs) are a common way to generate them. PRNGs use algorithms to generate a sequence of numbers that appear random, but are actually deterministic. This can be helpful for a variety of purposes, such as simulating random events, shuffling cards in a game etc.

the java.util.Random class is a commonly used PRNG, but it has some limitations. It uses a linear congruential generator (LCG) algorithm, which is not considered very secure, and it does not offer comprehensive options for customization.

To address these issues, JDK has introduced JEP 356: Enhanced Pseudo-Random Number Generators. This new feature adds a new java.util.Random.SplittableRandom class, which uses a more advanced algorithm called a splitmix64 generator. splitmix64 generator is more secure than the LCG algorithm and renders better performance.

In addition to this new SplittableRandom class, JEP 356 also adds several new methods to the java.util.Random class, including methods for generating long, double, and boolean values with different probability distributions, and for generating streams of random values.

Overall, JEP 356: Enhanced Pseudo-Random Number Generators is a great addition to the JDK, providing developers with a more secure and customizable PRNG option for their programs.

Java 14 – Switch Expressions Click To Tweet

Example – JEP 356: Enhanced Pseudo-Random Number Generators

 

Output:

 

Java 14 – Switch Expressions Click To Tweet
convert intstream to integer array

Do you like this Post? – then check my other helpful posts:

Other Useful References: