We would like to know how to fill an array with random numbers.
import java.util.Arrays; import java.util.Random; // ww w.j a v a2s . c o m public class Main { private static double[] anArray; public static void main(String args[]) { anArray = new double[10]; Random rand = new Random(); for (int i = 0; i < 10; i++) { anArray[i] = rand.nextInt(); } System.out.println(Arrays.toString(anArray)); } }
The code above generates the following result.