[英]The method asList(T[]) in the type Arrays is not applicable for the arguments (int, int)
I am using jdk1.8.0_121 on eclipse kepler (My OS is windows 7), I have created a simple project contained one class with static main method.我在 eclipse kepler(我的操作系统是 windows 7)上使用 jdk1.8.0_121,我创建了一个简单的项目,其中包含一个带有静态 main 方法的类。
When I tried to create a list as follow当我尝试创建如下列表时
List l = Arrays.asList(1,2);
I got this error :我收到此错误:
The method asList(T[]) in the type Arrays is not applicable for the arguments (int, int).
Arrays 类型中的 asList(T[]) 方法不适用于参数 (int, int)。
In case anyone else comes across a similar issue, I found that I had this error because I was importing edu.emory.mathcs.backport.java.util.Arrays;
万一其他人遇到类似的问题,我发现我有这个错误,因为我正在导入
edu.emory.mathcs.backport.java.util.Arrays;
instead of java.util.Arrays;
而不是
java.util.Arrays;
I think you need to put an array as the parameter of asList.我认为您需要将一个数组作为 asList 的参数。 like:
喜欢:
int[] data = {1,2,3,4,5};
List list = Arrays.asList(data);
我遇到了同样的问题,比如错误导入的org.javers.common.collection.arrays
所以删除了那个并从 Utils Arrays 导入
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.