Java Arrays.asList on primitive array type produces unexpected List type [duplicate]

The problem is that Arrays.asList takes a parameter of T... array. The only applicable T when you pass the int[] is int[], as arrays of primitives will not be autoboxed to arrays of the corresponding object type (in this case Integer[]).

So you can do Arrays.asList(new Integer[] {1, 2, 3});.

Leave a Comment