Here is an example of a program that easily generates random numbers in Java.
int r = new java.util.Random().nextInt(* Upper limit of random numbers to be generated);
If you have import java.util. * At the beginning of the source, you can also write as follows.
int r = new Random().nextInt(* Upper limit of random numbers to be generated);
Reference: [Specifications of java.util.Random # nextInt (int)
double r = Math.random();
Recommended Posts