Java – NetBeans do not recognize arrayutil

I am using the following statement

int[] numList = ArrayUtil.randomIntArray(100,100);

I have imported it

import java.util.*;

So it is impossible to enter the correct course here I'm trying to create an array containing 100 numbers and fill the array with random numbers from 1 to 100, but NetBeans put a red line under "arrayutil". I scanned it with the mouse to read the error "symbol not found, symbol: variable arrayutil" why does this happen when I import all the required classes

thank you

Solution

If you want to use its library, you need to download and import Apache Commons It is not part of the standard Java API

Or create your own functions;

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;
}
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>