Random Numbers in Minitab
Here’s the translation of the Go random numbers example to Java, formatted in Markdown suitable for Hugo:
Java’s java.util.Random
class provides pseudorandom number generation.
The Random
class generates random numbers using a seed. By default, it uses the current time as a seed, which results in different random numbers each time you run the program. If you want reproducible random numbers, you can create a Random
object with a specific seed.
To run the program, compile it and then use java
to execute:
Some of the generated numbers may be different when you run the sample, except for the ones generated with a specific seed (the last two lines).
Note that Java’s Random
class doesn’t have an exact equivalent to Go’s PCG (Permuted Congruential Generator). Java uses a different algorithm for its pseudorandom number generation. However, the basic usage and concept remain similar.
See the Java Random class documentation for references on other random quantities that Java can provide.