Resolving Java Type Mismatch Error: Cannot Convert from List<int[]> to List<Integer>
The error "Type mismatch: cannot convert from List
int[] intArray = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 }; //Type mismatch: cannot convert from Listto List List integerList = Arrays.asList(intArray);
To fix this error, you need to convert the int arrays to Integer objects and create a List of Integer. Here's an example of how you can resolve this issue:
// 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 ListintList = new ArrayList (); for(int n : intArray) { intList.add(n); }