0

I have a project I can't seem to wrap my head around. The only part I do not understand is this: Repeat for 1,000 times Create a new array of 100,000 numbers. ect...

Is this code replicating what I need? It seems to be, but i'm not certain. I do not want a code answer, I want a step in the right direction.

int size = 100000;
int max = 100000; 
int[] array = new int[size];
int loop = 0; 

Random generator = new Random();


generator.nextInt(max); 


for (int i = 0; i<1000; i++)
{
    array [i] = generator.nextInt(max);
}
Andrew
  • 19
  • 1
  • 7

1 Answers1

1

Your code creates an array of 100000 elements, but only fills the 1000 first. I don't think that's what you want. You probably want to either loop between 0 and size, or have two loops that for each 1000, add 1000 elements to the array.

JP Moresmau
  • 7,388
  • 17
  • 31