The asList (T []) method in an array of type is not applicable for arguments (int, int)

I am using jdk1.8.0_121 on eclipse kepler (my OS is Windows 7), I created a simple project containing one class with a static main method.

When I tried to create a list by following

List l = Arrays.asList(1,2);

I got this error:

The asList (T []) method in an array of type is not applicable to arguments (int, int).

+4
source share
3 answers

If someone encounters a similar problem, I found that I had this error because I imported edu.emory.mathcs.backport.java.util.Arrays; instead java.util.Arrays;

+21
source

, asList. : int [] data = {1,2,3,4,5}; List = Arrays.asList();

+1

import arrays from java.util.Arrays;

0
source

Source: https://habr.com/ru/post/1674558/


All Articles