Random number generation in java.
This program shows, the method of generation of random numbers
in java.
To be able to use the random function,we need to import the random class.
The random numbers generated are stored in the array and printed out to the
terminal.
/******************************************** * Generating random numbers/array in Java * * code.cheraus.com ********************************************/ import java.util.Random; class Random_Array { public static void main(String args[]) { int arr[] = new int[10]; Random num = new Random(); for(int i=0;i<10;i++) arr[i] = num.nextInt(10); for(int i=0;i<10;i++) System.out.println(arr[i]); } }