To generate random numbers in Java programming, you have to create the object of Random class available in the java.util.Random package as shown in the following program.
Following Java program to generate random numbers: This code generates random numbers in range 0 to 10000
SOURCE CODE ::
import java.util.Scanner;
import java.util.Random;
public class Random_numbers{
public static void main(String[] args) {
int c;
Random t = new Random();
for (c = 1; c <= 15; c++) {
System.out.println(t.nextInt(10000));
}
}
}
Following Java program to generate random numbers: This code generates random numbers in range 0 to 10000
SOURCE CODE ::
OUTPUT ::
need an explanation for this answer? contact us directly to get an explanation for this answer