java netbeans 无法识别 ArrayUtil
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10674997/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
netbeans not recognizing ArrayUtil
提问by miatech
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
所以在这里导入正确的类是不可能的。我正在尝试创建一个包含 100 个数字的数组,并使用 1-100 之间的随机数填充该数组,但是 netbeans 在“ArrayUtil”下放置了一条红线,我用鼠标浏览它以读取错误“找不到符号, Symbol: variable ArrayUtil" 为什么在我导入了所有需要的类时会发生这种情况
Thanks
谢谢
回答by Jivings
You need to download and import Apache Commonsif you want to use their Libraries. It is not part of the standard Java API.
如果你想使用他们的库,你需要下载并导入Apache Commons。它不是标准 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;
}