Resolving Java Type Mismatch Error: Cannot Convert from List<int[]> to List<Integer>
This error Type mismatch: cannot convert from List<int[]> to List<Integer> occurs when you try to convert a List of Integer to an int Array. The following code will show this error:
int[] intArray = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
//Type mismatch: cannot convert from List<int[]> to List<Integer>
List<Integer> integerList = Arrays.asList(intArray);
To resolve this error, you should convert int [] to List in this way:
// sample list of int items
int[] intArray = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
// converting array of int into list of int
List<Integer> intList = new ArrayList<Integer>();
for(int n : intArray) {
intList.add(n);
}