简体   繁体   English

Arrays 类型中的 asList(T[]) 方法不适用于参数 (int, int)

[英]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.

相关问题 数组类型中的方法asList(T…)不适用于参数(角色,角色) - The method asList(T…) in the type Arrays is not applicable for the arguments (Role, Role) 类型中的方法不适用于参数(int) - The method in the type is not applicable for the arguments (int) 类型X中的方法X不适用于参数(int) - The method X in the type X is not applicable for the arguments (int) main类型的方法(double [])不适用于参数(int []) - The method (double[]) in the type main is not applicable for the arguments (int[]) ArrayBoss 类型中的方法 (int[]) 不适用于参数 () - The method (int[]) in the type ArrayBoss is not applicable for the arguments () FragmentTransaction类型的方法add(int,Fragment)不适用于参数(int,WeatherFragment) - The method add(int, Fragment) in the type FragmentTransaction is not applicable for the arguments (int, WeatherFragment) BufferedImage类型的方法getRGB(int,int)不适用于参数(..) - The method getRGB(int, int) in the type BufferedImage is not applicable for the arguments (..) prosedure_jsp类型的pro(int,int)方法不适用于参数() - The method pro(int, int) in the type prosedure_jsp is not applicable for the arguments () PreparedStatement 类型中的 setString(int, String) 方法不适用于参数 (int, String[]) - The method setString(int, String) in the type PreparedStatement is not applicable for the arguments (int, String[]) ArrayList 类型中的方法 set(int, Int)<int> 不适用于 arguments (int, int) 长度无法解析或不是字段</int> - The method set(int, Int) in the type ArrayList<Int> is not applicable for the arguments (int, int) length cannot be resolved or is not a field
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM