Fill an array with random numbers [duplicate]

You can use IntStream ints() or DoubleStream doubles() available as of java 8 in Random class. something like this will work, depends if you want double or ints etc.

Random random = new Random();

int[] array = random.ints(100000, 10,100000).toArray();

you can print the array and you’ll get 100000 random integers.

Leave a Comment