Thursday, December 17, 2009

Index 1001 Jpg Adding Random Numbers To An Array In Java?

Adding random numbers to an Array in Java? - index 1001 jpg

I'm trying to create a table, then fill it with random numbers that have values between 0 - 1000 My idea was to use a loop to add numbers randomly when I try to compile, but said he could not find the method add (int)) in the last line "classy.add (index. Therefore, my code is not correct, now, could someone fix the code and tell me why it works the correct version and why not me?

public class Lab8Array
(
/ / An array of type int
private int [] sort;
/ / An int to keep track of class size
private int counter;
/ / Create a random number to
Private Random random generator;

Public Lab8Array (int n)
(
class = new int [n];
count = n;
random = new Random ();
)

public void fillRandomly ()
(
u0026lt for (int i = 0 Tracker Tracker \\ \\ \\ \\ \\ \\ \\ \\; classy.length; Tracker + +)
(
int index = randomGenerator.nextInt (1001);
classy.add(index);
)
)
)

0 comments:

Post a Comment