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); } 
3
  • 2
    You are creating one array and setting the first 1000 values. You need an array of arrays. Commented Jul 27, 2015 at 16:36
  • stackoverflow.com/questions/4781100/… Commented Jul 27, 2015 at 16:40
  • 1
    Thank you. I don't know why this is being down voted, i'm sorry if I did something wrong Commented Jul 27, 2015 at 17:06

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.