To fill an array with random numbers in Java do this:
new Random().ints().limit(10).toArray()
.For example, here is how you can generate an array of 10
random integers:
import java.util.Random;
int[] tenRandomIntegers = new Random().ints().limit(10).toArray();
And here is how you can generate an array of 5
random fractional numbers:
import java.util.Random;
double[] tenRandomFractionalNumbers = new Random().ints().asDoubleStream().limit(5).toArray();