Arrays.setAll wont work with boolean

Viewed 334

I want to create a big array, and want to try out some lambda, but for some reason that:

cells = new boolean[this.collums][this.rows];
IntStream.range(0, cells.length).forEach(x -> Arrays.setAll(cells[x], e -> MathX.fastNextInt(1) == 0 ? true : false));

wont work, even that:

cells = new boolean[this.collums][this.rows];
IntStream.range(0, cells.length).forEach(x -> Arrays.setAll(cells[x], e -> true));

dose not work.

The compiler error is :

Type mismatch: cannot convert from boolean to T

and:

The method setAll(T[], IntFunction) in the type Arrays is not applicable for the arguments (boolean[], ( e) -> {})

2 Answers
Related