Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

netbeans not recognizing ArrayUtil

Tags:

java

netbeans

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

like image 785
miatech Avatar asked Mar 27 '26 19:03

miatech


2 Answers

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;
}
like image 59
Jivings Avatar answered Mar 31 '26 05:03

Jivings


You can download from here

The link is for commons lang 2.3

like image 21
JHS Avatar answered Mar 31 '26 05:03

JHS