How to convert an int[] array to a List?

tshepang :

I expected this code to display true:

int[] array = {1, 2};
System.out.println(Arrays.asList(array).contains(1));
aioobe :

The Arrays.asList(array) will result in a singleton list of an int[].

It works as you expect if you change int[] to Integer[]. Don't know if that helps you though.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related