I'm using the following statement
int[] numList = ArrayUtil.randomIntArray(100, 100);
and I have imported
import java.util.*;
so importing the right class is out of the question here. I'm trying to create an array of 100 numbers and populate the array with random numbers from 1-100, but netbeans is putting a red line under "ArrayUtil" I glance over it with my mouse to read the error "can not find symbol, Symbol: variable ArrayUtil" why is this happening when I have imported all needed classes
Thanks
You need to download and import Apache Commons if you want to use their Libraries. It is not part of the standard Java API.
Or create the function yourself;
public int[] randomIntArray(int length, int size) {
Random r = new Random();
int[] numbers = new int[length];
for(int i = 0; i < length; i++) {
numbers[i] = r.nextInt(size+1);
}
return numbers;
}
You can download from here
The link is for commons lang 2.3
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With