The inner one collect(Collectors.toList()returns a List<Integer>, and not ArrayList<Integer>, so you must put these inner ones Listin ArrayList<List<Integer>>:
ArrayList<List<Integer>> col =
Arrays.stream(data)
.map(i -> Arrays.stream(i)
.collect(Collectors.toList()))
.collect(Collectors.toCollection(ArrayList<List<Integer>>::new));
Alternatively, use Collectors.toCollection(ArrayList<Integer>::new)to collect elements of the inner Stream:
ArrayList<ArrayList<Integer>> col =
Arrays.stream(data)
.map(i -> Arrays.stream(i)
.collect(Collectors.toCollection(ArrayList<Integer>::new)))
.collect(Collectors.toCollection(ArrayList<ArrayList<Integer>>::new));
source
share